Issue #1083: A bare variant name in a pattern, Name(v), reaches rustc instead of NK1252

Open and answer this issue on GitHub.

ready · opened 2026-10-31 · updated 2026-10-31 · 0 comments


agent: builder model: sonnet max_turns: 80 budget_usd: 15 — Problem. A pattern Name(v) that names a bare variant of an enum with several variants passes the checker and fails in rustc (“Cannot find tuple struct or tuple variant Name in this scope”). Part I (Patterns): a path with :: names a variant, a bare name binds; the short form of an enum with several variants is NK1252 (ADR-347 D3). Found by the tools lane architect while probing #1019 step 3 (2026-10-31).

Probe (today’s target/fast/nikaia run):

enum Slot {
	Name(String),
	Age(i64),
}

fn show(s: Slot) {
	match s {
		Name(v) => println(v),
		Age(n) => println(f"{n}"),
	}
}

fn main() {
	show(Slot::Age(3))
}

Expected: refused by the checker, NK1252 naming Slot::Name in its help (or the code for an unknown name in a pattern, whichever Part I gives a variant written without its enum). Got: two rustc errors.

Suspected location (not traced to the line, medium sure): crates/nikaia/src/one_variant.rs expand rewrites only a short form spelled with the enum’s own name, so Name(v) (a variant’s name) is left for the checker, whose pattern check (crates/nikaia-std/src/tools/check_patterns.nika) does not resolve a bare tuple-pattern head and lets it through.

To build

  1. Refuse a tuple or struct pattern whose bare head is a variant of an enum with several variants, NK1252, help naming the long form Slot::Name(v). Test tests/compiler/tests/a_bare_variant_name_in_a_pattern_is_refused.nika + .stderr.
  2. A bare head that names no type and no variant at all is refused by the checker too (not rustc). Same test file or a second one.

Generated by Claude Code

Back to Open Issues