Skip to content

Resolve bare symbols in calls to GlobalRefs on Julia 1.12+ - #164

Merged
CarloLucibello merged 1 commit into
masterfrom
cl/bare-symbols
Oct 15, 2026
Merged

CarloLucibello merged 1 commit into
masterfrom
cl/bare-symbols

Conversation

@CarloLucibello

Copy link
Copy Markdown
Member

Fixes #90.

On Julia 1.12+, a bare symbol in an inserted call no longer resolves in the module of the method being compiled. An example is pushfirst!(ir, :(println("hi"))), as in the insert!/pushfirst! docstrings. The symbol ends up as Core.println, which throws a MethodError. On 1.10 it resolved in the module the CodeInfo is compiled in.

update! now pins bare symbols in :call statements to GlobalRefs, on 1.12+ only. The module matches what 1.10 does:

  • @dynamo: the dynamo's own module, i.e. the module of the generated entry method. It is not the module of the function being rewritten.
  • func(m, ir)/evalir(m, ...): always m.
  • Bare update!(ci, ir): the IR's method module, or Main if there is none.

The tests cover a dynamo in one module rewriting a function from another, for both a function dynamo and a callable-struct dynamo, and evalir into a given module with and without Meta. Bare symbols nested inside other expressions, or under non-:call heads, are not rewritten.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.72%. Comparing base (9aa34fc) to head (6fb0dee).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/reflection/dynamo.jl 70.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #164      +/-   ##
==========================================
+ Coverage   77.70%   77.72%   +0.02%     
==========================================
  Files          16       16              
  Lines        1619     1634      +15     
==========================================
+ Hits         1258     1270      +12     
- Misses        361      364       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CarloLucibello
CarloLucibello force-pushed the cl/bare-symbols branch 2 times, most recently from ca8c5c3 to cb04454 Compare October 15, 2026 15:59
Since Julia 1.12 a bare symbol in a `:call` of a hand-built `CodeInfo` is
no longer resolved in the module the code is compiled in, so e.g.
`:(println(...))` inserted into IR hit `Core.println` instead of
`Main.println`. Before building the `IRCode`, `update!` now turns bare
symbols in call expressions into `GlobalRef`s on 1.12+. The module
matches 1.10: the one passed to `func`/`evalir`, or the module of the
`@dynamo` entry method; a bare `update!` defaults to the IR's method
module, else `Main`. Quoted symbols and non-call expressions are left alone.

Fixes #90.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@CarloLucibello
CarloLucibello merged commit 0abd0b6 into master Oct 15, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bugreport: Everything crashes when running an example from the docstring

1 participant