Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import Enzyme:
allocatedinline,
ismutabletype,
create_fresh_codeinfo,
add_edge!
add_edge!,
LookupError

using Enzyme

import EnzymeCore
Expand Down Expand Up @@ -6270,7 +6272,7 @@ function thunk_generator(world::UInt, source::Union{Method, LineNumberNode}, @no

mi = my_methodinstance(Mode == API.DEM_ForwardMode ? Forward : Reverse, ft, primal_tt, world, min_world, max_world)

mi === nothing && return stub(world, source, :(throw(MethodError($ft, $primal_tt, $world))))
mi === nothing && return stub(world, source, :(throw(LookupError($ft, $primal_tt, $world))))

check_activity_cache_invalidations(world)

Expand Down Expand Up @@ -6389,7 +6391,7 @@ function deferred_id_generator(world::UInt, source::Union{Method, LineNumberNode

mi = my_methodinstance(Mode == API.DEM_ForwardMode ? Forward : Reverse, ft, primal_tt, world, min_world, max_world)

mi === nothing && return stub(world, source, :(throw(MethodError($ft, $primal_tt, $world))))
mi === nothing && return stub(world, source, :(throw(LookupError($ft, $primal_tt, $world))))

target = EnzymeTarget()
rt2 = if A isa UnionAll
Expand Down
2 changes: 1 addition & 1 deletion src/typeutils/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function primal_return_type_generator(world::UInt, source, self, @nospecialize(m
slotnames,
Core.svec(),
)
mi === nothing && return stub(world, source, :(throw(MethodError(ft, tt, $world))))
mi === nothing && return stub(world, source, :(throw(LookupError(ft, tt, $world))))

result = primal_return_type_world(mode, world, mi)
code = Any[Core.Compiler.ReturnNode(result)]
Expand Down
22 changes: 19 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,22 @@ end
end


struct LookupError <: Exception
ft::Type
tt::Type
world::UInt
end

function Base.showerror(io::IO, e::LookupError)
print(io, "no method matching ")
Base.show_signature_function(io, e.ft)
Base.show_tuple_as_call(io, :function, e.tt; hasfirst=false, kwargs=nothing)
if Core._hasmethod(GPUCompiler.signature_type_by_tt(e.ft, e.tt))
print(io, "\n(method exists but is not available in world age $(e.world))")
end
end


"""
create_fresh_codeinfo(fn, source, world)

Expand Down Expand Up @@ -378,9 +394,9 @@ function methodinstance_generator(world::UInt, source, self, @nospecialize(mode:
min_world = Ref{UInt}(typemin(UInt))
max_world = Ref{UInt}(typemax(UInt))
mi = my_methodinstance(mode.instance, ft, tt, world, min_world, max_world)
mi === nothing && return stub(world, source, :(throw(MethodError(ft, tt, $world))))

mi === nothing && return stub(world, source, :(throw(LookupError($ft, $tt, $world))))

code = Any[Core.Compiler.ReturnNode(mi)]

ci = create_fresh_codeinfo(prevmethodinstance, source, world, slotnames, code)
Expand Down
Loading