agent: builder model: opus max_turns: 100 budget_usd: 20 —

Brief: a match over error that names a struct error type by its name (#673)

Found while reviewing #673 step 1 (commits std::regex: run-time patterns… and keeps: a parameter of a generic type…, local on develop, not pushed). Part I, Telling failures apart: a match over error “is complete when it names every type that can arrive: each variant of it, or the type by a bare name”. For an error type that is a struct this does not hold.

Facts (probes on the current target/fast/nikaia, built from this tree)

To build

  1. Checker: a bare type name or a type path (Bad, regex::Error, io::IoError) as an arm’s pattern in a match over error covers that member of the error set; the match is complete when every member that can arrive is covered (Part I). A name that is not a type in the set keeps its existing refusal.
  2. Lowering: such an arm is lowered as the arm for that member, never as a Rust binding or a Rust path pattern; no rustc message or warning reaches the user.
  3. Tests in Nikaia (tests/compiler/tests/, .nika + .stdout): a program struct error caught by its name; two program struct error types arriving at one catch, each named, the right arm taken for each (no else); regex::Error caught by its path without else (probe A); one with a type that cannot arrive, keeping today’s refusal (.stderr). Run each once against the unfixed compiler (stash the fix) and say in Tests: that it failed there.
  4. Rewrite tests/compiler/tests/regex_a_bad_pattern_is_a_regex_error.nika without its wrapper function: regex::dynamic("(") catch { match error { regex::Error => … } } directly in main, the .stdout unchanged.

Done when

target/fast/nikaia test --both-settings --project tests/compiler (all, it is a check//emit/ change); the guard set of .claude/agents/builder.md; clippy clean; lower-std at its fixpoint. One commit per step that stands alone (the fix with its tests; the regex test rewrite), Part of #673. Commit, do not push: the supervisor pushes the step-1 commits and these together. Changelog: one line under Changelog:.

Stop and report if

The error set’s representation cannot tell two struct types apart without a design choice (report it under Owner:); a .stderr outside your tests that would change; an error in another agent’s file.

Read docs/builder-facts.md.

Rules (CLAUDE.md; this block is pasted into every brief, also a fix-forward)

Report (at most 15 lines, to exactly /home/user/Nikaia/docs/briefs/b673b-catch-by-struct-type.md.report.md)

Fields of docs/architect.md, Briefs and reports: Result: done|noop|partial|blocked (the bare word alone), Files, Commit, Body (optional), Fixes, Pushed (no, by the brief), Tests, Gate (green|red), Deviation, Found, Needs, Changelog, Owner, Disk freed, Rs2nika: none. none where nothing, as the bare word. Final answer, one line: done <sha>, report <path> (or BLOCKED: ...).

This site is open source. Improve this page.