Skip to content

Commit 6c7cdb5

Browse files
authored
Don't rely on implicit binding creation by setglobal (#102)
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
1 parent 3b889ee commit 6c7cdb5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/clusterserialize.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ function deserialize_global_from_main(s::ClusterSerializer, sym)
167167
return nothing
168168
end
169169
end
170+
Core.eval(Main, Expr(:global, sym))
170171
if sym_isconst
171172
ccall(:jl_set_const, Cvoid, (Any, Any, Any), Main, sym, v)
172173
else
173-
setglobal!(Main, sym, v)
174+
invokelatest(setglobal!, Main, sym, v)
174175
end
175176
return nothing
176177
end

0 commit comments

Comments
 (0)