Skip to content

fix: reach_script read a binding younger than the frame reading it - #22

Merged
sotashimozono merged 3 commits into
mainfrom
fix/reach-script-world-age
Sep 6, 2026
Merged

fix: reach_script read a binding younger than the frame reading it#22
sotashimozono merged 3 commits into
mainfrom
fix/reach-script-world-age

Conversation

@sotashimozono

Copy link
Copy Markdown
Member

reach_script evaluates a script's top-level const lines into a scratch module and then analyses
a thunk that names them. The walk reads globals out of the IR, so it reaches a binding created
after its own caller was entered:

WARNING: Detected access to binding `ReachScript_figure.jl.RESULT` in a world prior to its
definition world.
!!! This code will error in future versions of Julia.

Two per full suite run, scrolling past a green suite. Base.invokelatest at the boundary is the
fix Julia's own hint names.

The test cost two attempts, and both failures are the interesting part

Each produced a test that could not fail:

  1. It has to call reach_script from inside a function. A caller's world age is fixed when it
    is entered; at top level it moves with every statement. The first version called it at top
    level and passed against the unfixed package.
  2. The child must run with the default depwarn. Measured on 1.12.2, --depwarn=error
    suppresses this warning rather than promoting it — the opposite of what the warning's own
    hint says — so the second version passed for the same reason as the first.

Verified in both directions: fails against the unfixed reach.jl with the warning text in the
child's stderr, passes with it.

🤖 Generated with Claude Code

`reach_script` evaluates a script's top-level `const` lines into a scratch module and then
analyses a thunk that names them. The walk reads globals out of the IR, so it reaches a binding
created after its own caller was entered — and Julia 1.12 says what that is:

    WARNING: Detected access to binding `ReachScript_figure.jl.RESULT` in a world prior to its
    definition world.
    !!! This code will error in future versions of Julia.

Two per full suite run, scrolling past a green suite. `Base.invokelatest` at the boundary is the
fix Julia's own hint names.

The test that pins it cost two attempts, and both failures are worth recording because each
produced a test that could not fail:

  * It has to call `reach_script` from inside a **function**. A caller's world age is fixed when
    it is entered; at top level it moves with every statement, and the first version of this test
    passed against the unfixed package because of that.
  * The child must run with the **default** `depwarn`. Measured on 1.12.2: `--depwarn=error`
    *suppresses* this warning rather than promoting it — the opposite of what the warning's own
    hint says — so the second version passed for the same reason as the first.

Verified in both directions: the test fails against the unfixed `reach.jl` with the warning text
in the child's stderr, and passes with it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Something isn't working label Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

📚 Docs preview: https://codes.sota-shimozono.com/ExperimentalAPI.jl/previews/PR22/

(updates on each push to this PR)

`test/spec/test_spec_lifecycle.jl` gained the world-age testset, so its behaviour count moved
15 → 16 and the total 178 → 179. The table in `test/spec/README.md` is generated and pinned by
`test/test_spec_table.jl`, which is what caught this — the hand-written version drifted inside the
change that introduced it, which is why it is pinned at all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
# Conflicts:
#	test/spec/README.md
@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sotashimozono
sotashimozono merged commit 0e6080f into main Sep 6, 2026
14 checks passed
@sotashimozono
sotashimozono deleted the fix/reach-script-world-age branch September 6, 2026 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant