Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused comprehension throws "iterate(nothing)" method error #804

Closed
FHell opened this issue Oct 3, 2020 · 1 comment · Fixed by #951
Closed

Unused comprehension throws "iterate(nothing)" method error #804

FHell opened this issue Oct 3, 2020 · 1 comment · Fixed by #951

Comments

@FHell
Copy link

FHell commented Oct 3, 2020

MWE:

using Zygote

function h(x)
    [2 for i in 1:2]
    sum(x)
end

gradient(h, zeros(2)) # ERROR: MethodError: no method matching iterate(::Nothing)
@mcabbott
Copy link
Member

mcabbott commented Oct 5, 2020

Complete error:

julia> gradient(h, zeros(2))
ERROR: MethodError: no method matching iterate(::Nothing)
Closest candidates are:
  iterate(::IRTools.Inner.IR) at /Users/me/.julia/packages/IRTools/GVPoj/src/ir/ir.jl:613
  iterate(::IRTools.Inner.IR, ::Any) at /Users/me/.julia/packages/IRTools/GVPoj/src/ir/ir.jl:613
  iterate(::IRTools.Inner.Pipe) at /Users/me/.julia/packages/IRTools/GVPoj/src/ir/ir.jl:875
  ...
Stacktrace:
 [1] _zip_iterate_some at ./iterators.jl:352 [inlined]
 [2] _zip_iterate_some at ./iterators.jl:354 [inlined]
 [3] _zip_iterate_all at ./iterators.jl:344 [inlined]
 [4] iterate at ./iterators.jl:334 [inlined]
 [5] iterate at ./generator.jl:44 [inlined]
 [6] collect(::Base.Generator{Base.Iterators.Zip{Tuple{Array{typeof((#9)),1},Nothing}},Base.var"#3#4"{Zygote.var"#493#497"}}) at ./array.jl:686
 [7] map(::Function, ::Array{typeof(∂(#9)),1}, ::Nothing) at ./abstractarray.jl:2248
 [8] (::Zygote.var"#492#496"{Array{typeof((#9)),1}})(::Nothing) at /Users/me/.julia/packages/Zygote/chgvX/src/lib/array.jl:187
 [9] (::Zygote.var"#520#521"{Zygote.var"#492#496"{Array{typeof((#9)),1}}})(::Nothing) at /Users/me/.julia/packages/Zygote/chgvX/src/lib/array.jl:203
 [10] h at ./REPL[13]:2 [inlined]
 [11] (::typeof((h)))(::Float64) at /Users/me/.julia/packages/Zygote/chgvX/src/compiler/interface2.jl:0
 [12] (::Zygote.var"#41#42"{typeof((h))})(::Float64) at /Users/me/.julia/packages/Zygote/chgvX/src/compiler/interface.jl:45
 [13] gradient(::Function, ::Array{Float64,1}) at /Users/me/.julia/packages/Zygote/chgvX/src/compiler/interface.jl:54
 [14] top-level scope at REPL[14]:1

So it looks like the problem is in ∇map, around here:

Δf_and_args_zipped = $mapfunc((f, δ) -> f(δ), _tryreverse($mapfunc, backs, Δ)...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants