@which and applicable report uncallable method


Am I correct in thinking this is a bug in Julia ?

julia> applicable(iterate,Int)

julia> iterate(Int)
ERROR: MethodError: no method matching iterate(::Type{Int64})
Closest candidates are:
  iterate(::Any) at essentials.jl:821

julia> @which iterate(Int)
iterate(x) in Base at essentials.jl:821

The same happens with other types, such as Regex.

I am using

Version 0.7.0-beta.99
Commit 0a77e89cd5 (2 days old master)


There’s a fallback definition for compatibility with the old iteration protocol that defines a generic iterate method. If it then finds neither the old nor the new iteration protocol, it throws an iterate method error of the kind that you should define. If you want to find out whether there’s a non fallback definition available, you can use Base.isiterable, which filters out the fallback definition.


I think this will work for me. I was unable to find the information elsewhere.

Btw. This came up because I want to call a function recursively on anything I can map over. In v0.6.x I had been using applicable(start, x) as a proxy for applicable(map, identity, x). In v0.7-beta, the latter also returns true for cases in which map(identity, x) throws an error, because it ultimately calls iterate.