ChainRulesCore.jl
ChainRulesCore.jl copied to clipboard
Get rid of `MethodError: no method matching iterate(::Nothing)`
This frequent error happens because of the default dispatches
frule(ȧrgs, f, ::Vararg{Any}) = nothing
rrule(::Any, ::Vararg{Any}) = nothing
so when no rrule is defined, nothing is returned.
Unfortunately, it is hard to catch because the computations with nothing can go on for a while before erroring.
I wonder if removing these default dispatches would break something badly?
right now removing them would break Diffractor for sure, which actually uses the isnothing to decide if it is going to recurse.
And it would break Zygote that looks at the best matching method is that fallback.
I think a solid case can be made to remove them in 2.0 though. I am sure we can work out a way to detect that case that is better.