Skip to content

Commit

Permalink
Don't recurse lowering symbol renaming through Expr(:toplevel)
Browse files Browse the repository at this point in the history
Fixes #53729.
  • Loading branch information
Keno committed Mar 13, 2024
1 parent 929dc76 commit 1d73b36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5131,7 +5131,7 @@ f(x) = yt(x)
((nospecialize-meta? e)
;; convert nospecialize vars to slot numbers
`(meta ,(cadr e) ,@(map renumber-stuff (cddr e))))
((or (atom? e) (quoted? e) (eq? (car e) 'global))
((or (atom? e) (quoted? e) (eq? (car e) 'global) (eq? (car e) 'toplevel))
e)
((ssavalue? e)
(let ((idx (get ssavalue-table (cadr e) #f)))
Expand Down
4 changes: 4 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3669,3 +3669,7 @@ let nnames = length(names(MacroHygieneGenerator; all=true))
@test (MacroHygieneGenerator.@gen3) == Bool[false]
@test length(names(MacroHygieneGenerator; all=true)) == nnames
end

# Issue #53729 - Lowering recursion into Expr(:toplevel)
@test eval(Expr(:let, Expr(:block), Expr(:block, Expr(:toplevel, :(f53729(x) = x)), :(x=1)))) == 1
@test f53729(2) == 2

0 comments on commit 1d73b36

Please sign in to comment.