@@ -85,10 +85,10 @@ Since the contents of such expression are difficult to analyze, it is generally
8585safest to execute all such evals.
8686"""
8787function minimal_evaluation! (@nospecialize (predicate), methodinfo, mod:: Module , src:: Core.CodeInfo , mode:: Symbol )
88- edges = CodeEdges (src)
88+ edges = CodeEdges (mod, src)
8989 # LoweredCodeUtils.print_with_code(stdout, src, edges)
9090 isrequired = fill (false , length (src. code))
91- namedconstassigned = Dict {Symbol ,Bool} ()
91+ namedconstassigned = Dict {GlobalRef ,Bool} ()
9292 evalassign = false
9393 for (i, stmt) in enumerate (src. code)
9494 if ! isrequired[i]
@@ -99,18 +99,24 @@ function minimal_evaluation!(@nospecialize(predicate), methodinfo, mod::Module,
9999 end
100100 end
101101 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
104107 elseif isexpr (stmt, :(= ))
105108 lhs = (stmt:: Expr ). args[1 ]
106109 if isa (lhs, Symbol)
110+ lhs = GlobalRef (mod, name)
111+ end
112+ if isa (lhs, GlobalRef)
107113 if haskey (namedconstassigned, lhs)
108114 namedconstassigned[lhs] = true
109115 end
110116 end
111117 if mode === :evalassign
112118 evalassign = isrequired[i] = true
113- if isa (lhs, Symbol )
119+ if isa (lhs, GlobalRef )
114120 isrequired[edges. byname[lhs]. succs] .= true # mark any `const` statements or other "uses" in this block
115121 end
116122 end
@@ -119,7 +125,7 @@ function minimal_evaluation!(@nospecialize(predicate), methodinfo, mod::Module,
119125 if mode === :sigs
120126 for (name, isassigned) in namedconstassigned
121127 isassigned || continue
122- if isdefined (mod, name)
128+ if isdefined (name . mod, name . name)
123129 empty! (edges. byname[name]. succs) # avoid redefining `consts` in `:sigs` mode (fixes #789)
124130 end
125131 end
@@ -225,7 +231,7 @@ function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, mod
225231 Core. eval (mod, ex)
226232 catch err
227233 (always_rethrow || isa (err, InterruptException)) && rethrow (err)
228- loc = location_string (whereis (frame)... )
234+ loc = location_string (whereis (frame))
229235 bt = trim_toplevel! (catch_backtrace ())
230236 throw (ReviseEvalException (loc, err, Any[(sf, 1 ) for sf in stacktrace (bt)]))
231237 end
@@ -248,7 +254,7 @@ function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, mod
248254 methods_by_execution! (recurse, methodinfo, docexprs, frame, isrequired; mode= mode, kwargs... )
249255 catch err
250256 (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))
252258 sfs = [] # crafted for interaction with Base.show_backtrace
253259 frame = JuliaInterpreter. leaf (frame)
254260 while frame != = nothing
@@ -309,10 +315,13 @@ function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, fra
309315 # However, it might have been followed by a thunk that defined a
310316 # method (issue #435), so we still need to check for additions.
311317 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
316325 end
317326 end
318327 pc = next_or_nothing! (frame)
0 commit comments