Skip to content

tools/rt_in_unit_sweep.w does not run: top-level ROOT invisible inside fn in_glob #1067

Closed

Description

@eas4ai

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.

Evidence: .audit/modules/tools__rt_in_unit_sweep.w.md, .audit/probes/tools_rt_in_unit_sweep/bounded_run.txt

Activity

  1. ehartford commented on Sep 16, 2026

    @ehartford
    Contributor

    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:
      let ROOT = "x/"
      fn uses_root(p: &str) -> bool: p.starts_with(ROOT)   // error: undefined variable 'ROOT'
      
    • const at module scope IS visible:
      const ROOT = "x/"
      fn uses_root(p: &str) -> bool: p.starts_with(ROOT)   // runs, prints true
      

    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.

  2. ehartford commented on Oct 25, 2026

    @ehartford
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions