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
tools/rt_in_unit_sweep.w does not run: top-level ROOT invisible inside fn in_glob #1067
At 450733e, the committed D30 lane-sweep tool fails before running anything:
$ out/bootstrap/bin/with-stage1 run tools/rt_in_unit_sweep.w /tmp/lane-fails.txt 1
error: undefined variable
--> tools/rt_in_unit_sweep.w:22:57
22 | if not path.ends_with(".w") or not path.starts_with(ROOT): return false
| ^^^^
error: undefined variable
--> tools/rt_in_unit_sweep.w:23:20
23 | not path.slice(ROOT.len(), path.len()).contains("/")
| ^^^^
error: run failed
The top-level let ROOT = "test/behavior/" (:17) is not visible inside fn in_glob. Reproduced identically under the tree-built stage2, so it is not a stale seed. If top-level lets are main-locals by rule, the tool is stale and should take the root as a parameter or inline the literal; if they should be visible, this is a compiler scoping bug. Either way the committed tool does not run.
Review: reproduced (stale tool, not a compiler bug)
Verdict. Reproduced: tools/rt_in_unit_sweep.w fails to run with undefined variable on ROOT at lines 22-23. The report's open question resolves in favor of "stale tool": a top-level let is a local of the implicit-main body, not a module global, so it is correctly invisible inside fn in_glob. A module-level const is visible. The compiler behavior is correct per spec; the tool uses the wrong declaration form.
Tested.
Source
main @ 5809ac1 (2026-09-14); tools/rt_in_unit_sweep.w unchanged since the reported revision 450733e
Compilers
with v0.15.2.1 built from 5809ac1 (staging worktree); a compiler built from 450733e with the nightly-20260903 seed. Identical error
Platform
macOS Darwin 25.6.0 arm64
with run tools/rt_in_unit_sweep.w <out> 1, both compilers:
error: undefined variable
--> tools/rt_in_unit_sweep.w:22:57
22 | if not path.ends_with(".w") or not path.starts_with(ROOT): return false
plus the same on ROOT at line 23.
Resolving the report's disjunction (minimal probes).
Top-level let invisible in a fn — reproduced in isolation:
So top-level executable statements (including a top-level let) are the implicit-main body, and a let there is a main-local, not a module global. Spec §18.5 confirms: "top-level executable statements ... a form defined for CLI entry sources ... not a general module feature." A sibling fn therefore cannot see a top-level let, by design. This is not a compiler scoping bug; const is the module-constant form and it works.
Root cause. The tool declares let ROOT = "test/behavior/" at tools/rt_in_unit_sweep.w:17 and reads it inside fn in_glob (:22-23); the let is an implicit-main local not in scope for the function. Established by the probes above; no debugger needed.
Severity. Low: an internal D30 lane-sweep tool that does not run. No user-facing impact.
Related. No open PR. Same "committed tool has rotted" family as #1066 (lib/test) and the tests/ drift issues, though the mechanism here is scoping, not syntax.
Recommendation — champion, one-line fix. Change let ROOT to const ROOT (visible to the functions), or pass the root as a parameter to in_glob/sweep. Acceptance criteria: with run tools/rt_in_unit_sweep.w <out> 1 runs to completion; ideally a note in the tool that module-shared constants use const, since top-level let is a main-local.
Not tested. The tool's actual sweep logic beyond the scoping failure (it never reaches it). Linux/Windows not exercised.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): superseded. tools/rt_in_unit_sweep.w was deleted in f95b8f8 (D30 step 4, #2500): "the runtime bundle is the only path; WITH_RT_IN_UNIT and the .w-derived runtime objects are gone". The tool swept the lane that no longer exists.
Activity
ehartford commentedon Sep 16, 2026
Review: reproduced (stale tool, not a compiler bug)
Verdict. Reproduced:
tools/rt_in_unit_sweep.wfails to run withundefined variableonROOTat lines 22-23. The report's open question resolves in favor of "stale tool": a top-levelletis a local of the implicit-main body, not a module global, so it is correctly invisible insidefn in_glob. A module-levelconstis visible. The compiler behavior is correct per spec; the tool uses the wrong declaration form.Tested.
main@ 5809ac1 (2026-09-14);tools/rt_in_unit_sweep.wunchanged since the reported revision 450733ewith v0.15.2.1built from 5809ac1 (staging worktree); a compiler built from 450733e with the nightly-20260903 seed. Identical errorwith run tools/rt_in_unit_sweep.w <out> 1, both compilers:plus the same on
ROOTat line 23.Resolving the report's disjunction (minimal probes).
letinvisible in afn— reproduced in isolation:constat module scope IS visible:So top-level executable statements (including a top-level
let) are the implicit-main body, and aletthere is a main-local, not a module global. Spec §18.5 confirms: "top-level executable statements ... a form defined for CLI entry sources ... not a general module feature." A siblingfntherefore cannot see a top-levellet, by design. This is not a compiler scoping bug;constis the module-constant form and it works.Root cause. The tool declares
let ROOT = "test/behavior/"attools/rt_in_unit_sweep.w:17and reads it insidefn in_glob(:22-23); theletis an implicit-main local not in scope for the function. Established by the probes above; no debugger needed.Severity. Low: an internal D30 lane-sweep tool that does not run. No user-facing impact.
Related. No open PR. Same "committed tool has rotted" family as #1066 (
lib/test) and thetests/drift issues, though the mechanism here is scoping, not syntax.Recommendation — champion, one-line fix. Change
let ROOTtoconst ROOT(visible to the functions), or pass the root as a parameter toin_glob/sweep. Acceptance criteria:with run tools/rt_in_unit_sweep.w <out> 1runs to completion; ideally a note in the tool that module-shared constants useconst, since top-levelletis a main-local.Not tested. The tool's actual sweep logic beyond the scoping failure (it never reaches it). Linux/Windows not exercised.
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): superseded.tools/rt_in_unit_sweep.wwas deleted in f95b8f8 (D30 step 4, #2500): "the runtime bundle is the only path; WITH_RT_IN_UNIT and the .w-derived runtime objects are gone". The tool swept the lane that no longer exists.