Skip to content

Commit 1b2eecb

Browse files
minor inferrability improvements for Base.StackTraces.StackFrame(::Frame) (#494)
* minor inferrability improvements for `Base.StackTraces.StackFrame(::Frame)` * Update src/packagedef.jl Co-authored-by: Kristoffer Carlsson <[email protected]> * more readable form Co-authored-by: Kristoffer Carlsson <[email protected]>
1 parent 560f3ac commit 1b2eecb

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/packagedef.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ else
4646
end
4747
end
4848

49+
if !isdefined(Base, Symbol("@something"))
50+
macro something(x...)
51+
:(something($(map(esc, x)...)))
52+
end
53+
end
54+
4955
include("types.jl")
5056
include("utils.jl")
5157
include("construct.jl")

src/utils.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,9 @@ show_stackloc(frame) = show_stackloc(stdout, frame)
695695

696696
# Printing of stacktraces and errors with Frame
697697
function Base.StackTraces.StackFrame(frame::Frame)
698-
if scopeof(frame) isa Method
699-
method = frame.framecode.scope
698+
scope = scopeof(frame)
699+
if scope isa Method
700+
method = scope
700701
method_args = something.(frame.framedata.locals[1:method.nargs])
701702
atypes = Tuple{mapany(_Typeof, method_args)...}
702703
sig = method.sig
@@ -709,8 +710,8 @@ function Base.StackTraces.StackFrame(frame::Frame)
709710
end
710711
Base.StackFrame(
711712
fname,
712-
Symbol(JuliaInterpreter.getfile(frame)),
713-
JuliaInterpreter.linenumber(frame),
713+
Symbol(getfile(frame)),
714+
@something(linenumber(frame), getline(linetable(frame, 1))),
714715
mi,
715716
false,
716717
false,

0 commit comments

Comments
 (0)