Issue #2185: a warning inside a match bound by a let points at the let, not at its…

Open and answer this issue on GitHub.

decision, bugs · opened 2026-11-19 · updated 2026-11-22 · 3 comments

Filed by the driver from the Found: of the run of issue-1625 (#1625) (owner, 2026-11-06).

Found

a warning inside a match bound by a let points at the let, not at its expression: struct F { value: i64? } / fn main() { let fields: Vec[F] = [F { value: 3 }, F { value: null }]; for field in fields { let part = match field.value { null => 0, given => given ?? 0, }; println(part) } } gives NK1216 at 6:9 (let part = match ...) where the ?? is at line 8; let names = match false { true => "", false => "use a::{{B, C}};", } gives NK1111 at the let line too; the warning should point at the ?? or the string (it does for a ?? written directly in a let); suspected: the callers in check_fields.nika (NK1216) and check_host.nika unmarked_hole (NK1111) receive the enclosing statement’s span, not the expression’s; check: pass the expression’s span and run the probe

To build

Done when

The probe or check gives the expected output the first item names from its ADR or Part I-III section, and a tests/compiler/tests/ test (or the named check) that failed on the unfixed tree is green; or the probe already passes on develop and a test pins it, naming the commit that fixed it; or the issue is closed as by design, naming the function or ADR.


Generated by Claude Code

Comments

keywan-ghadami, 2026-11-22

Brief queued: issue-2185


agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —

Issue #2185

Your work order is issue #2185, inlined below with its comments. There is no brief written around it: plan your own steps from its To build list, build them in order, commit after each finished step, and end when its Done when holds (or at the limits of builder.md, reporting what is left). The facts in your prompt are Core of docs/builder-facts.md; more on a topic: nikaia run scripts/syntax.nika -- KEYWORD, a probe: nikaia run scripts/probe.nika -- SNIPPET.

Measure the issue against docs/issues.md while you work: what it lacked, what was wrong in it. That answer goes into the report’s Issue: field. A finding, a changed plan or a finished item also goes into the issue as a comment (gh api repos/Nikaia-Foundation/Nikaia/issues/2185/comments -F body=@file, ending with the Claude Code footer), rule I13.

Rules (CLAUDE.md; shared checkout)

Report (at most 15 lines, to exactly /home/user/Nikaia/docs/briefs/bugs/issue-2185.md.report.md)

Fields: Result, Files, Commit, Body (optional), Fixes, Pushed, Tests, Gate, Deviation, Found, Needs, Changelog, Issue, Owner (a question for the owner), Comment (#N <text>, what to say on another issue; the driver posts it, one line each), Friction, Disk freed, and last Attribution: with your commit trailer lines below it.


Generated by Claude Code

keywan-ghadami, 2026-11-22

Run: issue-2185, Result: done

Tokens: input 40, cache read 806281, cache write 38716, output 7101 Cost: 0.65 USD, time 1 min 22 s, turns 20

Report

Result: done Files: none Commit: none Body: closed as by design: ADR-024 D7 “A finding names the statement, not the expression” and ADR-300 D4 (“Expressions are not [recorded], so a type error inside a statement is reported on that statement: let x = f(g(y)) blames the whole let”); a match arm body is an expression (ast.nika MatchArm.body: Expr), so its enclosing statement is the let. Expressions carry no span (Expr::Coalesce { value, fallback, id }, Expr::LitStr { text, id }); only Expr::Binary has one (ADR-081 D1), and ADR-081 section 4 leaves “spans on every other expression” until something needs them. Probes on HEAD 7bf83a9c6 (target/fast/nikaia check): the issue’s match probe gives NK1216 at 6:9 on let part = match field.value {; let names = match false { true => "", false => "use a::{{B, C}};", } gives NK1111 at 2:5; and a ?? written directly in a let split over two lines (let part = / x ?? 0, x: i64) gives NK1216 at 3:5 on let part =, and let names = / "use a::{{B, C}};" gives NK1111 at 5:5: the direct form also points at the statement, so the two shapes behave alike. The callers (check_core_ops.nika check_core_ops_coalesce -> check_fields.nika nothing_to_fall_back_from; check_core_expr.nika check_core_expr_text -> check_host.nika unmarked_hole) pass on the statement span on purpose, since no expression span exists to pass. Pointing a caret inside a statement needs expression spans in the parser, which is a language-tooling decision (ADR-024 D7 waits on it), not a defect fix. Fixes: none Pushed: none Tests: none run beyond the probes in Body (nothing changed) Gate: green Deviation: none Found: none Needs: none Changelog: none Issue: wrong I7: the Found says the callers “receive the enclosing statement’s span, not the expression’s”, but no expression span exists to pass (only Expr::Binary carries one, ADR-081 D1), and its claim that a ?? written directly in a let points at the ?? is false: a two-line let part = / x ?? 0 gives NK1216 on the let line too, so a single-line let only looked right; broke I6: the behaviour is decided by ADR-024 D7 and ADR-300 D4, which the Found did not check Owner: should NK1216, NK1111 and other checker findings get expression-level spans (ADR-024 D7 says “the day expressions carry spans, both checks get narrower”), so that a warning inside a multi-line match arm points at its line and not the let? Comment: none Friction: none Disk freed: none (cache target/nikaia-project-tests 560M, / 13G free; no new entry over 100 MB) Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDutPTwP5Xj5HkGuidk

Debrief

  1. What cost the most: about 8 turns finding out that the checker’s findings are keyed to statements. I grepped the two warning sites and their callers, found that Expr has no span field, then read ADR-081, ADR-300 and finally ADR-024 D7. Building and testing cost nothing: no build was needed and the binary was already current.
  2. What I looked up that the brief could have handed me: ADR-024 D7 (“a finding names the statement”) and ADR-300 D4 (expressions are not recorded). I also had to find that ast.nika Expr::Coalesce and Expr::LitStr carry only an id, and that only Expr::Binary has a span (ADR-081 D1).
  3. Checks run: the binary-vs-HEAD freshness check, the issue’s two probes (target/fast/nikaia check), one two-line direct-let probe, which disproved the issue’s comparison case, and the disk check. One probe was wasted: c.nika, an i64? coalesce that cannot warn at all.
  4. One change that would have saved the most: have the driver test a Found: that claims a wrong caret position against syntax.nika -- span or ADR-024 D7 before filing it. Or give builder.md one line saying that checker findings point at statements by design.
  5. What the issue lacked:
    • wrong I7: it blamed the callers for passing the statement’s span, but no expression span exists to pass.
    • wrong I5: “it does point at the ?? written directly in a let” holds only because a one-line let puts the ?? on the same line.
    • broke I6: it did not check ADR-024 D7 or ADR-300 D4, which decide this behaviour.
    • knowledge: Core a checker CheckFinding span is the enclosing statement’s; only Expr::Binary carries its own span.
  6. Fact: Core Checker findings point at the enclosing statement by design (ADR-024 D7, ADR-300 D4), so a caret on a multi-line statement’s first line is no defect: probe the direct form over two lines before filing.
    Fact: Probes To test a claim about which line a warning lands on, split the statement over several lines, since a one-line probe cannot tell the statement from the expression.
  7. Fact: none (I worked in no topic section; the only figures, 560M cache and 13G free on 2026-11-22 at 7bf83a9c6, are in the report).

One slip of mine: the report holds Fixes: none, which the rules forbid. It is harmless here because nothing was committed, but a later report should leave that line out.


Generated by Claude Code

keywan-ghadami, 2026-11-22

Question for the owner (from the bug lane’s run on this issue):

Should NK1216, NK1111 and the other checker findings get expression-level spans, so that a warning inside a multi-line match arm points at its own line and not at the let?

Today this is by design: ADR-024 D7 (“A finding names the statement, not the expression”) and ADR-300 D4 (a type error is reported on the statement); per ADR-081 D1/§4 only Expr::Binary carries a span. ADR-024 D7 itself foresees the change “the day expressions carry spans”.

The bug lane has taken this issue out of its queue until the answer comes.


Generated by Claude Code

Back to Open Issues