Skip to content

Commit

Permalink
Merge pull request JuliaLang#17257 from JuliaLang/teh/emptytt_subtype
Browse files Browse the repository at this point in the history
Type{Tuple{}} should not be a subtype of Type{Tuple}. Fixes JuliaLang#17198
  • Loading branch information
timholy authored Jul 3, 2016
2 parents be46ceb + 44a786a commit a647167
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2609,7 +2609,7 @@ static int jl_tuple_subtype_(jl_value_t **child, size_t clenr,
if (cseq && !pseq)
break;
if (ci >= clenf) {
result = pi >= plenf || pseq;
result = pi >= plenf || (pseq && !invariant);
break;
}
if (pi >= plenf && !pseq)
Expand Down
7 changes: 5 additions & 2 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ isnot(x,y) = !is(x,y)
@test !(Type{Rational{Int}} <: Type{Rational})
@test Tuple{} <: Tuple{Vararg}
@test Tuple{} <: NTuple{TypeVar(:N,true)}
@test Type{Tuple{}} <: Type{Tuple{Vararg}}
@test Type{Tuple{}} <: Type{NTuple{TypeVar(:N,true)}}
@test !(Type{Tuple{}} <: Type{Tuple{Vararg}})
@test !(Type{Tuple{}} <: Type{NTuple{TypeVar(:N,true)}})
let T = TypeVar(:T,true)
@testintersect(Array{Bottom},AbstractArray{T}, Bottom, isnot)
@testintersect(Tuple{Type{Ptr{UInt8}},Ptr{Bottom}},
Expand Down Expand Up @@ -307,6 +307,9 @@ nttest1{n}(x::NTuple{n,Int}) = n
@test Tuple{Vararg{Int32}} <: NTuple{TypeVar(:T),Int32}
@test Tuple{Int32,Vararg{Int32}} <: NTuple{TypeVar(:T),Int32}

# #17198
@test_throws MethodError convert(Tuple{Int}, (1.0, 2.0, 3.0))

# type declarations

abstract Sup_{A,B}
Expand Down

0 comments on commit a647167

Please sign in to comment.