Skip to content

Commit c0ae551

Browse files
martinholterssimeonschaub
authored andcommitted
Prune egal types when forming a Union (JuliaLang#37207)
Fixes JuliaLang#37180.
1 parent cfa922d commit c0ae551

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/jltypes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ JL_DLLEXPORT jl_value_t *jl_type_union(jl_value_t **ts, size_t n)
499499
if (j != i && temp[i] && temp[j]) {
500500
if (temp[i] == temp[j] || temp[i] == jl_bottom_type ||
501501
temp[j] == (jl_value_t*)jl_any_type ||
502+
jl_egal(temp[i], temp[j]) ||
502503
(!has_free && !jl_has_free_typevars(temp[j]) &&
503504
jl_subtype(temp[i], temp[j]))) {
504505
temp[i] = NULL;

test/subtype.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,3 +1766,6 @@ end
17661766
@testintersect(Tuple{Type{T}, AbstractVector{T}} where T,
17671767
Tuple{Union, F36869{Int64, Missing}},
17681768
Tuple{Union, F36869{Int64, Missing}})
1769+
1770+
# issue #37180
1771+
@test !(typeintersect(Tuple{AbstractArray{T}, VecOrMat{T}} where T, Tuple{Array, Any}).body.parameters[1] isa Union)

0 commit comments

Comments
 (0)