Issue #1223: Lowering: a string chosen by if and passed to a String? parameter lowers as Some(&str) (E0308)

Open and answer this issue on GitHub.

ready · opened 2026-11-04 · updated 2026-11-04 · 0 comments

A string literal chosen by an if expression, bound with let and then passed to a String? parameter, lowers as Some(help) with help: &str. rustc then refuses the result with E0308 (mismatched types).

Probe:

fn show(help: String?) { println(help ?? "none") }

fn main() {
    let c = true
    let help = if c { "a" } else { "b" }
    show(help)
}

Found by the views brief v3 (commit 6f97fbcf). To get past it, that commit wraps the chosen word in an f-string in crates/nikaia-std/src/tools/check_keep_marks.nika (the let help = f"Write {written}, as the trait does." line). That is debt and comes out with the fix.

To build

  1. The lowering converts the &str to String (or binds the let as String) when the value goes into a String? parameter. Add the probe as a test under tests/compiler/.
  2. Put the plain if form back in check_keep_marks.nika and run the lower-std fixpoint.

Back to Open Issues