Skip to content

Commit 832e182

Browse files
authored
Merge pull request #103 from JuliaDebug/teh/fix_98
optimize!: don't look up GlobalRefs on the lhs of an assignment
2 parents c0e481d + a2ae106 commit 832e182

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Manifest.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
55

66
[[CodeTracking]]
77
deps = ["Test", "UUIDs"]
8-
git-tree-sha1 = "591b73b37c92ed7d55d3a14e266829c21aa3a7eb"
8+
git-tree-sha1 = "12aa4d41c7926afd7a71af5af603a4d8b94292c2"
99
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
10-
version = "0.3.0"
10+
version = "0.3.1"
1111

1212
[[Distributed]]
1313
deps = ["Random", "Serialization", "Sockets"]

src/JuliaInterpreter.jl

+1
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ end
759759
function lookup_global_refs!(ex::Expr)
760760
(ex.head == :isdefined || ex.head == :thunk || ex.head == :toplevel) && return nothing
761761
for (i, a) in enumerate(ex.args)
762+
ex.head == :(=) && i == 1 && continue # Don't look up globalrefs on the LHS of an assignment (issue #98)
762763
if isa(a, GlobalRef)
763764
r = getfield(a.mod, a.name)
764765
ex.args[i] = QuoteNode(r)

test/interpret.jl

+10
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ let x = Core.TypedSlot(1, Any)
280280
@test isa(@interpret(f(x)), UInt)
281281
end
282282

283+
# issue #98
284+
x98 = 5
285+
function f98()
286+
global x98
287+
x98 = 7
288+
return nothing
289+
end
290+
@interpret f98()
291+
@test x98 == 7
292+
283293
# Some expression can appear nontrivial but lower to nothing
284294
@test isa(JuliaInterpreter.prepare_thunk(Main, :(@static if ccall(:jl_get_UNAME, Any, ()) == :NoOS 1+1 end)), Nothing)
285295
@test isa(JuliaInterpreter.prepare_thunk(Main, :(Base.BaseDocs.@kw_str "using")), Nothing)

0 commit comments

Comments
 (0)