@@ -277,12 +277,11 @@ function linetable(arg)
277
277
return ci. linetable:: Union{Vector{Core.LineInfoNode},Vector{Any}} # issue #264
278
278
end # @static if
279
279
end
280
- function linetable (arg, i:: Integer ; macro_caller:: Bool = false ):: Union{Expr,Nothing,LineTypes}
280
+ function linetable (arg, i:: Integer ; macro_caller:: Bool = false , def = : var"n/a" ):: Union{Expr,Nothing,LineTypes}
281
281
lt = linetable (arg)
282
282
@static if VERSION ≥ v " 1.12.0-DEV.173"
283
283
# TODO : decode the linetable at this frame efficiently by reimplementing this here
284
- # TODO : get the contextual name from the parent, rather than returning "n/a" (which breaks Cthulhu)
285
- nodes = Base. IRShow. buildLineInfoNode (lt, :var"n/a" , i)
284
+ nodes = Base. IRShow. buildLineInfoNode (lt, def, i)
286
285
isempty (nodes) && return nothing
287
286
return nodes[1 ] # ignore all inlining / macro expansion / etc :(
288
287
else # VERSION < v"1.12.0-DEV.173"
@@ -389,10 +388,13 @@ method that issued the macro.
389
388
function CodeTracking. whereis (framecode:: FrameCode , pc:: Int ; kwargs... )
390
389
codeloc = codelocation (framecode. src, pc)
391
390
codeloc == 0 && return nothing
392
- lineinfo = linetable (framecode, codeloc; kwargs... )
393
- lineinfo === nothing && return nothing
394
391
m = framecode. scope
395
- return isa (m, Method) ? whereis (lineinfo, m) : (getfile (lineinfo), getline (lineinfo))
392
+ lineinfo = linetable (framecode, codeloc; kwargs... , def= isa (m, Method) ? m : :var"n/a" )
393
+ if m isa Method
394
+ return lineinfo === nothing ? (String (m. file), m. line) : whereis (lineinfo, m)
395
+ else
396
+ return lineinfo === nothing ? nothing : (getfile (lineinfo), getline (lineinfo))
397
+ end
396
398
end
397
399
CodeTracking. whereis (frame:: Frame , pc:: Int = frame. pc; kwargs... ) = whereis (frame. framecode, pc; kwargs... )
398
400
0 commit comments