Array{Any} when collecting chained generators
Collecting a generator works as expected
julia> collect(i for i=1:10)
10-element Array{Int64,1}:
1
2
3
4
5
6
7
8
9
10
But if you chain it
julia> collect(chain(i for i=1:10))
10-element Array{Any,1}:
1
2
3
4
5
6
7
8
9
10
What puzzles me is that eltype(i for i=1:10) == Any
eltype(i for i=1:10) == Any is an issue, I think. But probably an issue for JuliaLang/julia. I figure there could be two solutions:
- Something involving
Base.return_typesto do inference on the generator function in the general case
OR
- Special case a generator which just returns the results of an iterator (I think this would need some parser attention, i.e., have the parser use
identityinstead of(x)->xso that we can dispatch on it after.
eltype(i for i=1:10) == Anyis an issue,
It's not an issue.
- Something involving
Base.return_typesto do inference on the generator function in the general case
And we shouldn't do this.
I think we just shouldn't rely on eltype in collect.
I wasn't sure whether Base.return_types was fair game or not.
I was thinking up some @generated solution until I realized that I can tell collect to not rely on eltype fairly simply. This line solves things:
Base.iteratoreltype(c::Chain) = EltypeUnknown()
but we may not need it with #85 (reviewing performance for that now). We will.
fixed by #85
No, it wasn't
ouch, sorry, did the wrong test, ranges instead of iterators
That's okay :)