Issue #1258: Lowering: a map read handed to a lent String? / fs::Path? does not compile

Open and answer this issue on GitHub.

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

A map read handed to a lent option parameter does not compile, for text as well as for a path.

Probe

fn shown(p: String?) -> Int {
    match p {
        some(s) => s.len()
        none => 0
    }
}

fn main() {
    var m: HashMap[String, String] = HashMap::new()
    m.insert("k", "v")
    print(shown(m["k"]))
}

The same with fn shown(p: ref String?).

It lowers to (*nikaia_std::index::get(&m, ..)).as_deref(), an Option<&String>, where Option<&str> is expected (#1256: a lent String? is Option<&str>). emit_arg_a_map_read does not recognise this shape, so the map-read rewrite in emit_core_args.nika never runs. It already fails before the fix for fs::Path? (83f5d097).

To build

Part of #1256.


Generated by Claude Code

Back to Open Issues