Skip to content

Commit

Permalink
Prune egal types when forming a Union (#37207)
Browse files Browse the repository at this point in the history
Fixes #37180.

(cherry picked from commit f047d7f)
  • Loading branch information
martinholters authored and JeffBezanson committed Sep 8, 2020
1 parent bb3ff89 commit fa6055c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ JL_DLLEXPORT jl_value_t *jl_type_union(jl_value_t **ts, size_t n)
if (j != i && temp[i] && temp[j]) {
if (temp[i] == temp[j] || temp[i] == jl_bottom_type ||
temp[j] == (jl_value_t*)jl_any_type ||
jl_egal(temp[i], temp[j]) ||
(!has_free && !jl_has_free_typevars(temp[j]) &&
jl_subtype(temp[i], temp[j]))) {
temp[i] = NULL;
Expand Down
3 changes: 3 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1764,3 +1764,6 @@ end
@testintersect(Tuple{Type{T}, AbstractVector{T}} where T,
Tuple{Union, F36869{Int64, Missing}},
Tuple{Union, F36869{Int64, Missing}})

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

0 comments on commit fa6055c

Please sign in to comment.