Skip to content

Commit

Permalink
fix tuple_type_head and tuple_type_tail on UnionAll
Browse files Browse the repository at this point in the history
Ref #22911
(cherry picked from commit 763d008)
  • Loading branch information
JeffBezanson authored and vtjnash committed Sep 14, 2017
1 parent affd292 commit 6ec7078
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ end
argtail(x, rest...) = rest
tail(x::Tuple) = argtail(x...)

tuple_type_head(T::UnionAll) = tuple_type_head(T.body)
tuple_type_head(T::UnionAll) = (@_pure_meta; UnionAll(T.var, tuple_type_head(T.body)))
function tuple_type_head(T::DataType)
@_pure_meta
T.name === Tuple.name || throw(MethodError(tuple_type_head, (T,)))
return unwrapva(T.parameters[1])
end
tuple_type_tail(T::UnionAll) = tuple_type_tail(T.body)
tuple_type_tail(T::UnionAll) = (@_pure_meta; UnionAll(T.var, tuple_type_tail(T.body)))
function tuple_type_tail(T::DataType)
@_pure_meta
T.name === Tuple.name || throw(MethodError(tuple_type_tail, (T,)))
Expand Down
4 changes: 4 additions & 0 deletions test/tuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,7 @@ end
for n = 0:15
@test ntuple(identity, Val{n}) == ntuple(identity, n)
end

# https://github.com/JuliaLang/julia/issues/21026#issuecomment-317113307
const VecTuple21026{T} = Tuple{VecElement{T}}
@test convert(VecTuple21026, (1,)) === (VecElement(1),)

0 comments on commit 6ec7078

Please sign in to comment.