I’m trying to get the function_filter
argument to the JET macro @report_opt
to work, without success. I guess I’m missing something. Here is an example:
f(x::T) where T = x > 0 ? 1 : error("illegal argument of type $T")
I get
julia> @report_opt f(1)
═════ 32 possible errors found ═════
┌ f(x::Int64) @ Main ./REPL[2]:1
│┌ string(::String, ::Type{Int64}) @ Base ./strings/io.jl:189
││┌ print_to_string(::String, ::Type{Int64}) @ Base ./strings/io.jl:148
│││┌ print(io::IOBuffer, x::DataType) @ Base ./strings/io.jl:35
││││┌ show(io::IOBuffer, x::DataType) @ Base ./show.jl:962
│││││┌ _show_type(io::IOBuffer, x::Type) @ Base ./show.jl:967
││││││┌ show_typealias(io::IOBuffer, x::Type) @ Base ./show.jl:802
│││││││┌ make_typealias(x::Type) @ Base ./show.jl:612
││││││││┌ modulesof!(s::Set{Module}, x::Type) @ Base ./show.jl:587
│││││││││ runtime dispatch detected: Base.modulesof!(s::Set{Module}, %20::Any)::Any
││││││││└────────────────────
and so on. All reported issues are related to the interpolation $T
. I could get rid of them by defining
f(x::T) where T = x > 0 ? 1 : error("illegal argument of type ", T)
but this is not the point here. (It’s an example!) Instead, I wan to use the function_filter
argument of @report_opt
. My understanding is that using function_filter = (g -> g != show)
would skip all calls to show
. But this is not the case. I get fewer reported issues, but they are still all inside show
:
julia> @report_opt function_filter = (g -> g != show) f(1)
═════ 13 possible errors found ═════
┌ f(x::Int64) @ Main ./REPL[2]:1
│┌ string(::String, ::Type{Int64}) @ Base ./strings/io.jl:189
││┌ print_to_string(::String, ::Type{Int64}) @ Base ./strings/io.jl:148
│││┌ print(io::IOBuffer, x::DataType) @ Base ./strings/io.jl:35
││││┌ show(io::IOBuffer, x::DataType) @ Base ./show.jl:962
│││││┌ _show_type(io::IOBuffer, x::Type) @ Base ./show.jl:967
││││││┌ show_typealias(io::IOBuffer, x::Type) @ Base ./show.jl:802
│││││││┌ make_typealias(x::Type) @ Base ./show.jl:612
││││││││┌ modulesof!(s::Set{Module}, x::Type) @ Base ./show.jl:587
│││││││││ runtime dispatch detected: Base.modulesof!(s::Set{Module}, %20::Any)::Any
││││││││└────────────────────
What am I doing wrong?
EDIT: Also, shouldn’t the default setting skip_unoptimized_throw_blocks::Bool = true
(see here) avoid an analysis of the error
branch in the first place?