String? / fs::Path? does not compileOpen 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.
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).
emit_arg_a_map_read (or the opening helpers in emit_core_args.nika) recognise a map read handed to a lent T?, and hand it through .map(std::ops::Deref::deref) to the parameter’s Option<&str> / Option<&[u8]> / Option<&Path>.tests/compiler/tests/ covering String?, ref String? and fs::Path? fed from a map read, at both settings.Part of #1256.
Generated by Claude Code