Open and answer this issue on GitHub.
ready · opened 2026-10-31 · updated 2026-10-31 · 0 comments
Found by j5 (docs/briefs/tools/j5-1019-comptime-field.md.report.md), tools lane. Part of ADR-246 D5 (#97 step 1: one level of a pattern inside a boxed part is lowered).
A pattern that looks inside a boxed part one level deep is lowered for a tuple variant, but not for a named-field variant: the generated Rust does not compile (Box<E> against E). The checker lets it through (no NK1193), so the user sees a rustc error.
enum E { Num(i64), Call { func: E, n: i64 } }
fn eval(e: E) -> i64 {
match e {
E::Call { func: E::Num(k), n } if n > 0 => k + n,
else => 0,
}
}
fn main() {
print(f"{eval(E::Call { func: E::Num(2), n: 3 })}")
}
Wanted: 5. Today: error: Mismatched types ... Expected struct Box<E>, found enum E. The tuple form (Call(E, i64), E::Call(E::Num(k), n)) works.
Every function that tells “this arm looks inside a box” handles MatchPattern::Tuple and Or only, not MatchPattern::Named: check_boxes.nika a_pattern_inside_a_box_at and looks_inside_a_box, emit_types.nika looks_inside_a_box, and the emitter’s guard that opens the boxed part (emit_core_match.nika around 1070; emit_misc.nika boxed_bindings already walks Named).
MatchPattern::Named as they take Tuple (a field of a variant by its name, boxed_member(variant, -1, field)), and the lowering opens the named boxed field as it opens a tuple part. Test tests/compiler/tests/a_pattern_looks_inside_a_boxed_named_field.nika + .stdout (the probe, plus an arm without guard).NK1193 as for a tuple: .stderr test.Generated by Claude Code