# JET: How to use the function\_filter argument?

**URL:** <https://discourse.julialang.org/t/jet-how-to-use-the-function-filter-argument/122470>\
**Category:** General Usage\
**Tags:** jet\
**Created:** [November 10, 2024, 8:20pm UTC](https://discourse.julialang.org/t/jet-how-to-use-the-function-filter-argument/122470 "2024-11-10T20:20:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthias314](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Post date:** [November 10, 2024, 8:20pm UTC](https://discourse.julialang.org/t/jet-how-to-use-the-function-filter-argument/122470/1 "2024-11-10T20:20:48Z")

</div>

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:

```julia
f(x::T) where T = x > 0 ? 1 : error("illegal argument of type $T")

```

I get

```julia
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

```julia
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
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](https://aviatesk.github.io/JET.jl/stable/optanalysis/#JET.OptAnalyzer)) avoid an analysis of the `error` branch in the first place?

---

<div class="post-metadata">

**Author:** ![kbarros](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kbarros/32/7723_2.png) [@kbarros](https://discourse.julialang.org/u/kbarros)\
**Post date:** [September 10, 2025, 2:19pm UTC](https://discourse.julialang.org/t/jet-how-to-use-the-function-filter-argument/122470/2 "2025-09-10T14:19:34Z")

</div>

I hit this problem too. This seems to be the relevant Github Issue, so I added your example: [shouldn't `function_filter` filter out all subsequent dynamic dispatches inside the ignored functions ? · Issue #694 · aviatesk/JET.jl · GitHub](https://github.com/aviatesk/JET.jl/issues/694).
