You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
t27c gen (Zig): test bindings shadow module vars, redeclare locals, and inherit param renames #6295
Found while lowering module-level vars in t27b (#6294). The Zig backend of t27c gen emits code that does not compile for three test-block shapes. t27c test-report therefore reports these specs as BLOCKED.
1. A top-level assignment to a module var in a test becomes a shadowing const
specs/fpga/testbench/spi_tb.t27, test test_cs_assert_during_transfer:
spi_start = true; // spi_start is a module-level var
This is emitted as var spi_start = true;, and Zig refuses it: "local variable shadows declaration of 'spi_start'".
The test-binding pass (compiler.rs, the fresh_binding loop in the Zig test emitter) declares the first assignment to any identifier. It does not check whether the name is a module declaration.
2. A local declared earlier in the test is declared again
specs/fpga/testbench/hir_tb.t27, test test_depth_limit:
var ok : bool = check_depth_limit(10);
ok = check_depth_limit(20);
This is emitted as var ok ...; const ok = ...;, and Zig refuses it: "redeclaration of local variable 'ok'".
The Zig bound set is not seeded with the block's StmtLocal names. The C path fixed the same defect in #2834.
Affected: hir_tb, axi4_tb, apb_bridge_tb.
3. Parameter renames leak into the following test
var counter: u32 = 0;
fn f(counter: u32) -> u32 { return counter + 1; }
test t { assert(counter == 0); }
counter in the test is emitted as counter_arg ("use of undeclared identifier"). param_renames (W735/W736) is cleared only at the start of the next fn, so it is still in force for every test, bench or invariant emitted after f. This also affects module consts and fns, not only vars.
t27b refuses all three shapes with named blockers, so there is no mismatch:
StmtAssign(module var in test)
StmtLocal(shadows module var)
ExprIdentifier(renamed module var)
For shape 2 (a plain local), t27b lowers the reassignment as a reassignment. That is the meaning of the spec, so hir_tb runs in t27b while the reference is BLOCKED. With the reassignment written as a fresh local, both report 7 pass and 1 fail (test_tick).
Seen again by the t27b [N]T lane (#6347): a test-local that shadows a module constant is not renamed by gen-zig, so zig refuses the file. t27b refuses the shape by name.
Dogfood (#6457): shape 2 blocks the self-hosted compiler spec. specs/compiler/core/t27core.t27, test minimal_module_compiles, generates var n: i64 = feed(...); _ = &n; const n = feed(0x3b, 1, n);, and Zig reports "redeclaration of local variable 'n'" (lab run 682564f, gen checked on the t27c lab). tri/crypto/rsa ('base') is likely the same, not traced.
Activity
gHashTag commentedon Oct 5, 2026
Seen again by the t27b [N]T lane (#6347): a test-local that shadows a module constant is not renamed by gen-zig, so zig refuses the file. t27b refuses the shape by name.
gHashTag commentedon Oct 5, 2026
Dogfood (#6457): shape 2 blocks the self-hosted compiler spec. specs/compiler/core/t27core.t27, test
minimal_module_compiles, generatesvar n: i64 = feed(...); _ = &n; const n = feed(0x3b, 1, n);, and Zig reports "redeclaration of local variable 'n'" (lab run 682564f, gen checked on the t27c lab). tri/crypto/rsa ('base') is likely the same, not traced.wip(gen-zig): test-block shadow handling (#6295)
wip(gen-zig): test-block shadow handling (#6295)
policy: owner-approved exception for the t27c gen-zig fixes (#6295)
wip: bench blocks (#6295)
fix(gen-zig): a test or bench block may shadow a module name and writ…
fix(gen-zig): a test or bench block may shadow a module name and writ…
chore(seals): reseal after the gen-zig shadowing fix; ledger 15 force…
fix(gen-c): a test's write to a module var writes the global (Closes #…
fix(gen-c): a test's write to a module var writes the global (Closes #…
fix(gen-c): a test's write to a module var writes the global (Closes #…
fix(gen-c): seven self-host blockers #6046-#6052 (Part of #5980) (#6939)
t27b: a module var written at the top of a test is a write to module …
feat(t27b): std.mem.eql/indexOf on byte slices and byte-array pointers (
fix(codegen): gen-rust enum order and gen-zig float-call cast (#6941) (…
t27b: a test's write to a local it declared is a write, as the refere…
t27b: a test local named for a module var (Closes #7668) (#7447)