@@ -85,10 +85,10 @@ Since the contents of such expression are difficult to analyze, it is generally
85
85
safest to execute all such evals.
86
86
"""
87
87
function minimal_evaluation! (@nospecialize (predicate), methodinfo, mod:: Module , src:: Core.CodeInfo , mode:: Symbol )
88
- edges = CodeEdges (src)
88
+ edges = CodeEdges (mod, src)
89
89
# LoweredCodeUtils.print_with_code(stdout, src, edges)
90
90
isrequired = fill (false , length (src. code))
91
- namedconstassigned = Dict {Symbol ,Bool} ()
91
+ namedconstassigned = Dict {GlobalRef ,Bool} ()
92
92
evalassign = false
93
93
for (i, stmt) in enumerate (src. code)
94
94
if ! isrequired[i]
@@ -99,18 +99,24 @@ function minimal_evaluation!(@nospecialize(predicate), methodinfo, mod::Module,
99
99
end
100
100
end
101
101
if isexpr (stmt, :const )
102
- name = stmt. args[1 ]:: Symbol
103
- namedconstassigned[name] = false
102
+ name = stmt. args[1 ]
103
+ if isa (name, Symbol)
104
+ name = GlobalRef (mod, name)
105
+ end
106
+ namedconstassigned[name:: GlobalRef ] = false
104
107
elseif isexpr (stmt, :(= ))
105
108
lhs = (stmt:: Expr ). args[1 ]
106
109
if isa (lhs, Symbol)
110
+ lhs = GlobalRef (mod, name)
111
+ end
112
+ if isa (lhs, GlobalRef)
107
113
if haskey (namedconstassigned, lhs)
108
114
namedconstassigned[lhs] = true
109
115
end
110
116
end
111
117
if mode === :evalassign
112
118
evalassign = isrequired[i] = true
113
- if isa (lhs, Symbol )
119
+ if isa (lhs, GlobalRef )
114
120
isrequired[edges. byname[lhs]. succs] .= true # mark any `const` statements or other "uses" in this block
115
121
end
116
122
end
@@ -119,7 +125,7 @@ function minimal_evaluation!(@nospecialize(predicate), methodinfo, mod::Module,
119
125
if mode === :sigs
120
126
for (name, isassigned) in namedconstassigned
121
127
isassigned || continue
122
- if isdefined (mod, name)
128
+ if isdefined (name . mod, name . name)
123
129
empty! (edges. byname[name]. succs) # avoid redefining `consts` in `:sigs` mode (fixes #789)
124
130
end
125
131
end
@@ -225,7 +231,7 @@ function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, mod
225
231
Core. eval (mod, ex)
226
232
catch err
227
233
(always_rethrow || isa (err, InterruptException)) && rethrow (err)
228
- loc = location_string (whereis (frame)... )
234
+ loc = location_string (whereis (frame))
229
235
bt = trim_toplevel! (catch_backtrace ())
230
236
throw (ReviseEvalException (loc, err, Any[(sf, 1 ) for sf in stacktrace (bt)]))
231
237
end
@@ -248,7 +254,7 @@ function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, mod
248
254
methods_by_execution! (recurse, methodinfo, docexprs, frame, isrequired; mode= mode, kwargs... )
249
255
catch err
250
256
(always_rethrow || isa (err, InterruptException)) && (disablebp && foreach (enable, active_bp_refs); rethrow (err))
251
- loc = location_string (whereis (frame)... )
257
+ loc = location_string (whereis (frame))
252
258
sfs = [] # crafted for interaction with Base.show_backtrace
253
259
frame = JuliaInterpreter. leaf (frame)
254
260
while frame != = nothing
@@ -309,10 +315,13 @@ function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, fra
309
315
# However, it might have been followed by a thunk that defined a
310
316
# method (issue #435), so we still need to check for additions.
311
317
if ! isempty (signatures)
312
- file, line = whereis (frame. framecode, pc)
313
- lnn = LineNumberNode (Int (line), Symbol (file))
314
- for sig in signatures
315
- add_signature! (methodinfo, sig, lnn)
318
+ loc = whereis (frame. framecode, pc)
319
+ if loc != = nothing
320
+ file, line = loc
321
+ lnn = LineNumberNode (Int (line), Symbol (file))
322
+ for sig in signatures
323
+ add_signature! (methodinfo, sig, lnn)
324
+ end
316
325
end
317
326
end
318
327
pc = next_or_nothing! (frame)
0 commit comments