Skip to content

Commit

Permalink
Fix type-equality involving Type{Union{}} (#37261)
Browse files Browse the repository at this point in the history
In particular, make `obviously_unequal(Type{Union{}}, Type{T} where
{Union{}<:T<:Union{}})` false. Fixes #37255

(cherry picked from commit 79a9ea0)
  • Loading branch information
martinholters authored and JeffBezanson committed Sep 8, 2020
1 parent fa6055c commit 30d5003
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ static int obviously_unequal(jl_value_t *a, jl_value_t *b)
if (jl_is_datatype(b)) {
jl_datatype_t *ad = (jl_datatype_t*)a;
jl_datatype_t *bd = (jl_datatype_t*)b;
if (a == (jl_value_t*)jl_typeofbottom_type && bd->name == jl_type_typename)
return obviously_unequal(jl_bottom_type, jl_tparam(bd, 0));
if (ad->name == jl_type_typename && b == (jl_value_t*)jl_typeofbottom_type)
return obviously_unequal(jl_tparam(ad, 0), jl_bottom_type);
if (ad->name != bd->name)
return 1;
int istuple = (ad->name == jl_tuple_typename);
Expand Down
3 changes: 3 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1767,3 +1767,6 @@ end

# issue #37180
@test !(typeintersect(Tuple{AbstractArray{T}, VecOrMat{T}} where T, Tuple{Array, Any}).body.parameters[1] isa Union)

# issue #37255
@test Type{Union{}} == Type{T} where {Union{}<:T<:Union{}}

0 comments on commit 30d5003

Please sign in to comment.