Skip to content

Commit 66f2c2d

Browse files
committed
Give better error message when hitting a builtin
1 parent a224388 commit 66f2c2d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/stage1/recurse_fwd.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ struct ∂☆new{N}; end
2727
function ∂☆nomethd(@nospecialize(args))
2828
throw(MethodError(primal(args[1]), map(primal, Base.tail(args))))
2929
end
30+
function ∂☆builtin((f_bundle, args...))
31+
f = primal(f_bundle)
32+
throw(DomainError(f, "No `ChainRulesCore.frule` found for the built-in function `$f`"))
33+
end
3034

3135
function perform_fwd_transform(world::UInt, source::LineNumberNode,
3236
@nospecialize(ff::Type{∂☆recurse{N}}), @nospecialize(args)) where {N}
@@ -36,6 +40,11 @@ function perform_fwd_transform(world::UInt, source::LineNumberNode,
3640
end
3741

3842
sig = Tuple{map(π, args)...}
43+
if sig.parameters[1] <: Core.Builtin
44+
return generate_lambda_ex(world, source,
45+
Core.svec(:ff, :args), Core.svec(), :(∂☆builtin(args)))
46+
end
47+
3948
mthds = Base._methods_by_ftype(sig, -1, world)
4049
if mthds === nothing || length(mthds) != 1
4150
# Core.println("[perform_fwd_transform] ", sig, " => ", mthds)

0 commit comments

Comments
 (0)