Skip to content

Commit 79a9ea0

Browse files
Fix type-equality involving Type{Union{}} (#37261)
In particular, make `obviously_unequal(Type{Union{}}, Type{T} where {Union{}<:T<:Union{}})` false. Fixes #37255
1 parent 662e24c commit 79a9ea0

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/subtype.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ static int obviously_unequal(jl_value_t *a, jl_value_t *b)
244244
if (jl_is_datatype(b)) {
245245
jl_datatype_t *ad = (jl_datatype_t*)a;
246246
jl_datatype_t *bd = (jl_datatype_t*)b;
247+
if (a == (jl_value_t*)jl_typeofbottom_type && bd->name == jl_type_typename)
248+
return obviously_unequal(jl_bottom_type, jl_tparam(bd, 0));
249+
if (ad->name == jl_type_typename && b == (jl_value_t*)jl_typeofbottom_type)
250+
return obviously_unequal(jl_tparam(ad, 0), jl_bottom_type);
247251
if (ad->name != bd->name)
248252
return 1;
249253
int istuple = (ad->name == jl_tuple_typename);

test/subtype.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,3 +1769,6 @@ end
17691769

17701770
# issue #37180
17711771
@test !(typeintersect(Tuple{AbstractArray{T}, VecOrMat{T}} where T, Tuple{Array, Any}).body.parameters[1] isa Union)
1772+
1773+
# issue #37255
1774+
@test Type{Union{}} == Type{T} where {Union{}<:T<:Union{}}

0 commit comments

Comments
 (0)