Open
Description
When taking the gradient of a function that uses a dict constructor using a generator or a list, it fails because there is a try/catch block somewhere.
e.g. for a generator
julia> using Zygote
julia> function f(x)
a = Dict(c => x for c in 1:3)
return a[1]
end
f (generic function with 1 method)
julia> Zygote.gradient(f, 2.0)
ERROR: Compiling Tuple{Type{Dict}, Base.Generator{UnitRange{Int64}, var"#3#4"{Float64}}}: try/catch is not supported.
It works however if I slurp the vector
julia> function f(x)
a = Dict([c => x for c in 1:3]...)
return a[1]
end
f (generic function with 1 method)
julia> Zygote.gradient(f, 2.0)
(1.0,)