JuliaLang / AllocCheck.jl

AllocCheck
Other
215 stars 8 forks source link

MethodError upon using `check_allocs` on a non-existent method #21

Closed topolarity closed 9 months ago

topolarity commented 10 months ago
julia> using AllocCheck

julia> function alloc_in_catch(x)
          try
              Base.inferencebarrier(nothing) # Prevent catch from being elided
          catch
              return Any[] # in catch block: filtered by `ignore_throw=true`
          end
          return Int64[]
       end
alloc_in_catch (generic function with 1 method)

julia> length(check_allocs(alloc_in_catch, (); ignore_throw=false))
ERROR: MethodError: no method matching alloc_in_catch()
<snip> ...

julia> function alloc_in_catch()
          return Int64[]
       end
alloc_in_catch (generic function with 2 methods)

julia> length(check_allocs(alloc_in_catch, (); ignore_throw=false))
ERROR: MethodError: no method matching alloc_in_catch()
The applicable method may be too new: running in world age 25448, while current world is 25449.
<snip> ...

The first MethodError is expected, but the second one is a surprise.

topolarity commented 10 months ago

Upstream issue: https://github.com/JuliaGPU/GPUCompiler.jl/issues/530