Skip to content

Commit

Permalink
Don't rely on implicit binding creation by setglobal (#102)
Browse files Browse the repository at this point in the history
As discussed in [1], the implicit creation of bindings through the
setglobal! intrinsic was accidentally added in 1.9 unintentionally
and will be removed (ideally) or at the very least deprecated in 1.11.

The recommended replacement syntax is `Core.eval(mod, Expr(:global, sym))` to
introduce the binding and `invokelatest(setglobal!, mod, sym, val)` to set
it. The invokelatest is not presently required, but may be required
for JuliaLang/julia#54654, so it's included
in the recommendation.

[1] JuliaLang/julia#54607
  • Loading branch information
Keno authored Jun 5, 2024
1 parent 3b889ee commit 6c7cdb5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/clusterserialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,11 @@ function deserialize_global_from_main(s::ClusterSerializer, sym)
return nothing
end
end
Core.eval(Main, Expr(:global, sym))
if sym_isconst
ccall(:jl_set_const, Cvoid, (Any, Any, Any), Main, sym, v)
else
setglobal!(Main, sym, v)
invokelatest(setglobal!, Main, sym, v)
end
return nothing
end
Expand Down

0 comments on commit 6c7cdb5

Please sign in to comment.