Skip to content

Commit a647167

Browse files
authored
Merge pull request #17257 from JuliaLang/teh/emptytt_subtype
Type{Tuple{}} should not be a subtype of Type{Tuple}. Fixes #17198
2 parents be46ceb + 44a786a commit a647167

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/jltypes.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2609,7 +2609,7 @@ static int jl_tuple_subtype_(jl_value_t **child, size_t clenr,
26092609
if (cseq && !pseq)
26102610
break;
26112611
if (ci >= clenf) {
2612-
result = pi >= plenf || pseq;
2612+
result = pi >= plenf || (pseq && !invariant);
26132613
break;
26142614
}
26152615
if (pi >= plenf && !pseq)

test/core.jl

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ isnot(x,y) = !is(x,y)
4545
@test !(Type{Rational{Int}} <: Type{Rational})
4646
@test Tuple{} <: Tuple{Vararg}
4747
@test Tuple{} <: NTuple{TypeVar(:N,true)}
48-
@test Type{Tuple{}} <: Type{Tuple{Vararg}}
49-
@test Type{Tuple{}} <: Type{NTuple{TypeVar(:N,true)}}
48+
@test !(Type{Tuple{}} <: Type{Tuple{Vararg}})
49+
@test !(Type{Tuple{}} <: Type{NTuple{TypeVar(:N,true)}})
5050
let T = TypeVar(:T,true)
5151
@testintersect(Array{Bottom},AbstractArray{T}, Bottom, isnot)
5252
@testintersect(Tuple{Type{Ptr{UInt8}},Ptr{Bottom}},
@@ -307,6 +307,9 @@ nttest1{n}(x::NTuple{n,Int}) = n
307307
@test Tuple{Vararg{Int32}} <: NTuple{TypeVar(:T),Int32}
308308
@test Tuple{Int32,Vararg{Int32}} <: NTuple{TypeVar(:T),Int32}
309309

310+
# #17198
311+
@test_throws MethodError convert(Tuple{Int}, (1.0, 2.0, 3.0))
312+
310313
# type declarations
311314

312315
abstract Sup_{A,B}

0 commit comments

Comments
 (0)