Skip to content

methodinstance(foo, types) returns MethodError permanently if method is not defined #530

@topolarity

Description

@topolarity
julia> using GPUCompiler

julia> function foo end
foo (generic function with 0 methods)

julia> methodinstance(Base._stable_typeof(foo), Base.to_tuple_type(()))
ERROR: MethodError: no method matching foo()
Stacktrace:
 [1] macro expansion
   @ GPUCompiler ~/.julia/packages/GPUCompiler/U36Ed/src/jlgen.jl:0 [inlined]
 [2] methodinstance(ft::Type{typeof(foo)}, tt::Type{Tuple{}})
   @ GPUCompiler ~/.julia/packages/GPUCompiler/U36Ed/src/jlgen.jl:123
 [3] top-level scope
   @ REPL[3]:1

julia> foo() = nothing
foo (generic function with 1 method)

julia> methodinstance(Base._stable_typeof(foo), Base.to_tuple_type(()))
ERROR: MethodError: no method matching foo()
The applicable method may be too new: running in world age 25447, while current world is 25448.

Closest candidates are:
  foo() (method too new to be called from this world context.)
   @ Main REPL[4]:1

Stacktrace:
 [1] macro expansion
   @ GPUCompiler ~/.julia/packages/GPUCompiler/U36Ed/src/jlgen.jl:0 [inlined]
 [2] methodinstance(ft::Type{typeof(foo)}, tt::Type{Tuple{}})
   @ GPUCompiler ~/.julia/packages/GPUCompiler/U36Ed/src/jlgen.jl:123
 [3] top-level scope
   @ REPL[5]:1

If I had made no mistake and defined the method before calling methodinstance:

julia> using GPUCompiler

julia> function foo end
foo (generic function with 0 methods)

julia> foo() = nothing
foo (generic function with 1 method)

julia> methodinstance(Base._stable_typeof(foo), Base.to_tuple_type(())).def
foo()
     @ Main REPL[3]:1

julia> foo() = nothing
foo (generic function with 1 method)

julia> methodinstance(Base._stable_typeof(foo), Base.to_tuple_type(())).def
foo()
     @ Main REPL[5]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions