Skip to content

Commit 8c3e60c

Browse files
authored
Add code_typed(::InvalidIRError) and print a hint about it. (#281)
1 parent 515c3e8 commit 8c3e60c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/reflection.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ function code_warntype(io::IO, @nospecialize(job::CompilerJob); interactive::Boo
7979
end
8080
code_warntype(@nospecialize(job::CompilerJob); kwargs...) = code_warntype(stdout, job; kwargs...)
8181

82+
InteractiveUtils.code_lowered(err::InvalidIRError; kwargs...) = code_lowered(err.job; kwargs...)
83+
InteractiveUtils.code_typed(err::InvalidIRError; kwargs...) = code_typed(err.job; kwargs...)
84+
InteractiveUtils.code_warntype(err::InvalidIRError; kwargs...) = code_warntype(err.job; kwargs...)
85+
8286
"""
8387
code_llvm([io], job; optimize=true, raw=false, dump_module=false)
8488

src/validation.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ function Base.showerror(io::IO, err::InvalidIRError)
101101
end
102102
Base.show_backtrace(io, bt)
103103
end
104+
println(io)
105+
printstyled(io, "HINT"; bold = true, color = :cyan)
106+
printstyled(
107+
io,
108+
": catch this exception as `err` and call `code_typed(err; interactive = true)` to",
109+
" introspect the erronous code";
110+
color = :cyan,
111+
)
104112
return
105113
end
106114

0 commit comments

Comments
 (0)