Skip to content

Commit

Permalink
Avoid form complex Any-like in simple_join.
Browse files Browse the repository at this point in the history
I gave up fixing the deep stack-overflow.
Make the `env` soundness seems much easier.

close #47874.
  • Loading branch information
N5N3 committed Jan 9, 2023
1 parent d0bd6a0 commit e0739d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,15 @@ static int obviously_disjoint(jl_value_t *a, jl_value_t *b, int specificity)
// compute a least upper bound of `a` and `b`
static jl_value_t *simple_join(jl_value_t *a, jl_value_t *b)
{
if (a == jl_bottom_type || b == (jl_value_t*)jl_any_type || obviously_egal(a,b))
if (a == (jl_value_t *)jl_any_type ||
b == (jl_value_t *)jl_any_type ||
//TODO: Add a fastpath for this check.
jl_subtype((jl_value_t *)jl_any_type, a) ||
jl_subtype((jl_value_t *)jl_any_type, b))
return (jl_value_t *)jl_any_type;
if (a == jl_bottom_type || obviously_egal(a,b))
return b;
if (b == jl_bottom_type || a == (jl_value_t*)jl_any_type)
if (b == jl_bottom_type)
return a;
if (!(jl_is_type(a) || jl_is_typevar(a)) || !(jl_is_type(b) || jl_is_typevar(b)))
return (jl_value_t*)jl_any_type;
Expand Down
6 changes: 6 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2317,6 +2317,12 @@ let S = Tuple{Int, Vararg{Val{C} where C<:Union{Complex{R}, R}}} where R
@test_broken typeintersect(T, S) == I
end

#issue #47874:case3
let S = Tuple{Int, Tuple{Vararg{Val{C1} where C1<:Union{Complex{R1}, R1}}} where R1<:(Union{Real, V1} where V1), Tuple{Vararg{Val{C2} where C2<:Union{Complex{R2}, Complex{R3}, R3}}} where {R2<:(Union{Real, V2} where V2), R3<:Union{Complex{R2}, Real, R2}}},
T = Tuple{Any, Tuple{Vararg{Val{CC1} where CC1<:Union{Complex{R}, R}}}, Tuple{Vararg{Val{CC2} where CC2<:Union{Complex{R}, R}}}} where R<:Real
@testintersect(S, T, !Union{})
end

let S = Tuple{T2, V2} where {T2, N2, V2<:(Array{S2, N2} where {S2 <: T2})},
T = Tuple{V1, T1} where {T1, N1, V1<:(Array{S1, N1} where {S1 <: T1})}
@testintersect(S, T, !Union{})
Expand Down

0 comments on commit e0739d3

Please sign in to comment.