I have trouble getting this to infer (on 1.3; but the same happens on 1.2):
function zipped_pairs_product(pairs)
itrs = map(pair -> zip(pair...), pairs)
vec(collect(Iterators.product(itrs...)))
end
pairs = (1:5 => 1:5, 2:3 => 2:3)
using Test; @inferred zipped_pairs_product(pairs) # nope
1 Like
But this apparently infers (only change is “manually splatting” args to zip):
function zipped_pairs_product2(pairs)
itrs = map(pair -> zip(pair[1], pair[2]), pairs)
vec(collect(Iterators.product(itrs...)))
end
Is this a known issue?
I also had problems with type inference of tuple zipping, to the point where I’ve just written these generated functions https://github.com/JuliaNLSolvers/Manifolds.jl/blob/0ac128450df3e2501764a27b7955362dbd9925c8/src/utils.jl#L74 . It’s the only reliably inferrable way to zip them that I know.
1 Like