We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eae3b4c commit ea522b8Copy full SHA for ea522b8
src/interpret.jl
@@ -372,17 +372,14 @@ function do_assignment!(frame, @nospecialize(lhs), @nospecialize(rhs))
372
counter = (frame.assignment_counter += 1)
373
data.locals[lhs.id] = Some{Any}(rhs)
374
data.last_reference[lhs.id] = counter
375
- elseif isa(lhs, GlobalRef)
+ elseif isa(lhs, Symbol) || isa(lhs, GlobalRef)
376
+ mod = lhs isa Symbol ? moduleof(frame) : lhs.mod
377
+ name = lhs isa Symbol ? lhs : lhs.name
378
+ Core.eval(mod, Expr(:global, name))
379
@static if @isdefined setglobal!
- setglobal!(lhs.mod, lhs.name, rhs)
380
+ setglobal!(mod, name, rhs)
381
else
- ccall(:jl_set_global, Cvoid, (Any, Any, Any), lhs.mod, lhs.name, rhs)
- end
- elseif isa(lhs, Symbol)
382
- @static if @isdefined setglobal!
383
- setglobal!(moduleof(code), lhs, rhs)
384
- else
385
- ccall(:jl_set_global, Cvoid, (Any, Any, Any), moduleof(code), lhs, rhs)
+ ccall(:jl_set_global, Cvoid, (Any, Any, Any), mod, name, rhs)
386
end
387
388
0 commit comments