Found by the t27b optionals lane (#6357), Refs #6063. Each is a t27c (parser or gen-zig) defect that makes the reference path refuse a well-formed spec:
if (x) |v| { ... } -- gen-zig drops the |v| capture; zig then reports v as undeclared. t27b refuses the shape as StmtIf(capture).
orelse does not parse in t27c.
- In a test block, a plain assignment
w = 9; to a name already declared with var is emitted as const w = 9;, a redeclaration zig rejects.
- A mutated pointer parameter is renamed to
var p = p_arg;, which zig rejects as "never mutated" when only p.* is written.
For 3 and 4, t27b currently passes such files while the reference does not compile them; they sit outside the 720 reference passes, so no count changes, but t27b should refuse them by name until the reference is fixed.
Boundary
bootstrap/src/compiler.rs
User Scenarios
- Given a spec with
if (x) |v| { use(v); }, when compiled by t27c, then the generated Zig must declare the capture v so the Zig compiler accepts it.
- Given a spec containing
orelse in an optional chain, when parsed by t27c, then the parser must accept the keyword and produce a valid AST node.
- Given a test block where
var w = 1; is followed by w = 9;, when codegen runs, then the reassignment must be emitted as a variable assignment, not a const redeclaration.
- Given a function taking a pointer parameter
p: *i32 that mutates p.*, when codegen renames the parameter, then the generated Zig must not emit var p = p_arg; if only p.* is written.
Requirements
- FR-001: The gen-zig backend MUST emit a capture variable for optional
if patterns so the Zig compiler sees the declared name.
- FR-002: The parser MUST recognize
orelse as a valid keyword in optional expressions and produce a corresponding AST node.
- FR-003: In test blocks, assignments to already-declared
var names MUST be emitted as mutable assignments, not const redeclarations.
- FR-004: When a pointer parameter is only mutated through dereference (
p.*), the codegen MUST NOT emit a var p = p_arg; shadow that Zig flags as never mutated.
Success Criteria
cargo test -p t27c -- optional_capture exits 0 and the generated Zig for if (x) |v| {} compiles without "undeclared identifier" errors.
cargo test -p t27c -- orelse_parse exits 0 and a spec containing orelse parses without syntax errors.
cargo test -p t27c -- test_reassign_const exits 0 and the emitted Zig for w = 9; inside a test block compiles without "redeclaration" errors.
cargo test -p t27c -- ptr_param_rename exits 0 and the emitted Zig for a mutated pointer parameter compiles without "never mutated" errors.
- All 720 reference specs in
specs/tools/tri/test.t27 still pass (t27c exit 0).
Found by the t27b optionals lane (#6357), Refs #6063. Each is a t27c (parser or gen-zig) defect that makes the reference path refuse a well-formed spec:
if (x) |v| { ... }-- gen-zig drops the|v|capture; zig then reportsvas undeclared. t27b refuses the shape asStmtIf(capture).orelsedoes not parse in t27c.w = 9;to a name already declared withvaris emitted asconst w = 9;, a redeclaration zig rejects.var p = p_arg;, which zig rejects as "never mutated" when onlyp.*is written.For 3 and 4, t27b currently passes such files while the reference does not compile them; they sit outside the 720 reference passes, so no count changes, but t27b should refuse them by name until the reference is fixed.
Boundary
bootstrap/src/compiler.rsUser Scenarios
if (x) |v| { use(v); }, when compiled by t27c, then the generated Zig must declare the capturevso the Zig compiler accepts it.orelsein an optional chain, when parsed by t27c, then the parser must accept the keyword and produce a valid AST node.var w = 1;is followed byw = 9;, when codegen runs, then the reassignment must be emitted as a variable assignment, not aconstredeclaration.p: *i32that mutatesp.*, when codegen renames the parameter, then the generated Zig must not emitvar p = p_arg;if onlyp.*is written.Requirements
ifpatterns so the Zig compiler sees the declared name.orelseas a valid keyword in optional expressions and produce a corresponding AST node.varnames MUST be emitted as mutable assignments, notconstredeclarations.p.*), the codegen MUST NOT emit avar p = p_arg;shadow that Zig flags as never mutated.Success Criteria
cargo test -p t27c -- optional_captureexits 0 and the generated Zig forif (x) |v| {}compiles without "undeclared identifier" errors.cargo test -p t27c -- orelse_parseexits 0 and a spec containingorelseparses without syntax errors.cargo test -p t27c -- test_reassign_constexits 0 and the emitted Zig forw = 9;inside a test block compiles without "redeclaration" errors.cargo test -p t27c -- ptr_param_renameexits 0 and the emitted Zig for a mutated pointer parameter compiles without "never mutated" errors.specs/tools/tri/test.t27still pass (t27cexit 0).