Skip to content

Commit

Permalink
fix iteratoreltype of Flatten
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 28, 2016
1 parent 181df3b commit b01d528
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/iterator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ flatten(itr) = Flatten(itr)

eltype{I}(::Type{Flatten{I}}) = eltype(eltype(I))
iteratorsize{I}(::Type{Flatten{I}}) = SizeUnknown()
iteratoreltype{I}(::Type{Flatten{I}}) = iteratoreltype(eltype(I))
iteratoreltype{I}(::Type{Flatten{I}}) = _flatteneltype(I, iteratoreltype(I))
_flatteneltype(I, ::HasEltype) = iteratoreltype(eltype(I))
_flatteneltype(I, et) = EltypeUnknown()

function start(f::Flatten)
local inner, s2
Expand Down
2 changes: 2 additions & 0 deletions test/functional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ import Base.flatten
@test eltype(flatten(UnitRange{Int8}[1:2, 3:4])) == Int8
@test_throws ArgumentError collect(flatten(Any[]))

@test Base.iteratoreltype(Base.Flatten((i for i=1:2) for j=1:1)) == Base.EltypeUnknown()

# foreach
let
a = []
Expand Down

0 comments on commit b01d528

Please sign in to comment.