Repository navigation
feat(t27b): module-level var as a writable global - #6296
Merged
Merged
Conversation
A typed module `var` with a compile-time initializer (scalar, enum, struct, array) lowers to ExprKind::Global backed by Program::globals. The JIT and the checked interpreter reset globals on every host entry, matching t27c test-report's one-process-per-test isolation. Object files refuse it as VarDecl(module, object file). Shapes the reference Zig cannot compile are refused by name: StmtAssign(module var in test), StmtLocal(shadows module var), ExprIdentifier(renamed module var), ExprIdentifier(var at comptime). Reference bugs filed as #6295. t27b corpus specs: pass 246 -> 258, rejected 687 -> 670, mismatch 0. Closes #6294 Refs #6063 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
This was referenced Oct 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6294
Refs #6063, #6295
What
This PR takes the
StmtAssign(undeclared)blocker family.varas a constant, so every assignment to it was refused.varwith a compile-time initializer (scalar, bool, enum, struct or array) lowers toExprKind::Global, backed byProgram::globals.depth == 0.t27c test-report, which runs each test in a fresh process.VarDecl(module, object file).Refused by name: the reference Zig cannot compile these
The reference bugs are filed as #6295.
StmtAssign(module var in test)const x = .., which shadows the container var (Zig error).StmtLocal(shadows module var)var x = x_arg, which shadows too.x->x_arg) and mentionsxExprIdentifier(renamed module var)param_renamesleaks into later tests.ExprIdentifier(var at comptime)VarDecl(module)t27b corpus specsNo file that passed before regressed.
12 newly passing files
Each one matches
t27c test-reportfrom the same master, test for test.specs/fpga/testbench/:assembler_tb(7)cts_tb(10)partition_tb(8)placement_tb(9)power_tb(8)router_tb(9)simulator_tb(6)specs/port/fpga/verilog/dsp_probe.t27(2)trinity_qmtech(5)led_d5_test(4)specs/ternary/clocked_counter.t27(1)specs/ternary/stream_ternary_mac.t27(4)New test fails and timeouts
test_fmax_computation). The reference fails the same test.test_tick).while !sync_ready { tick_fast(); }.Gaps left open
StmtAssign(undeclared)is a different shape, not lowered here:_ = expr;(31 files);i(3 files).Top 5 blockers after
ExprCall(assert with message): +19ExprIdentifier statement: +18FnDecl: +15ExprBinary statement: +12ExprCall(@compileAssert): +9🤖 Generated with Claude Code