diff --git a/Project.toml b/Project.toml index 6b3887a53..41b7c25ee 100644 --- a/Project.toml +++ b/Project.toml @@ -4,6 +4,7 @@ authors = ["Shuhei Kadowaki "] version = "0.9.0" [deps] +CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" JuliaInterpreter = "aa1ae85d-cabe-5617-a682-6adf51b2e16a" LoweredCodeUtils = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b" @@ -22,6 +23,7 @@ ReviseExt = "Revise" [compat] Aqua = "0.8.2" BenchmarkTools = "1.3.2" +CodeTracking = "1.3.1" Example = "0.5.3" InteractiveUtils = "1.10" JuliaInterpreter = "0.9" diff --git a/src/JET.jl b/src/JET.jl index 32ac500c8..6cb7ccf4c 100644 --- a/src/JET.jl +++ b/src/JET.jl @@ -47,6 +47,8 @@ using Base.Meta: ParseError, isexpr, lower using Base.Experimental: @MethodTable, @overlay +using CodeTracking: CodeTracking + using LoweredCodeUtils: LoweredCodeUtils, add_ssa_preds!, callee_matches using JuliaInterpreter: _INACTIVE_EXCEPTION, Frame, JuliaInterpreter, is_quotenode_egal diff --git a/src/ui/print.jl b/src/ui/print.jl index 6b5bceb75..a5c62358d 100644 --- a/src/ui/print.jl +++ b/src/ui/print.jl @@ -237,6 +237,15 @@ function print_frame_loc(io, frame, config, color) def = frame.linfo.def mod = def isa Module ? def : def.module path = String(frame.file) + line = frame.line + Δline = 0 + if def isa Method + # revise cached line number if method location has been updated + newline = CodeTracking.whereis(def)[2] + if newline != 0 + Δline = newline - Int(def.line) + end + end if config.fullpath path = tofullpath(path) elseif !isabspath(path) @@ -249,7 +258,7 @@ function print_frame_loc(io, frame, config, color) # end modulecolor = color printstyled(io, mod; color = modulecolor) - printstyled(io, ' ', path, ':', frame.line; color) + printstyled(io, ' ', path, ':', line+Δline; color) end function print_error_frame(io, report, config, depth)