Skip to content

Commit

Permalink
fix JuliaLang#38279, yet another bounds circularity in type intersect…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Nov 3, 2020
1 parent 2890a71 commit 2af16f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -2964,8 +2964,10 @@ static jl_value_t *intersect(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int pa
assert(yy->lb != y);
}
if (xx) {
xx->lb = y;
xx->ub = y;
if (!compareto_var(y, (jl_tvar_t*)x, e, -1))
xx->lb = y;
if (!compareto_var(y, (jl_tvar_t*)x, e, 1))
xx->ub = y;
assert(xx->ub != x);
}
JL_GC_POP();
Expand Down
9 changes: 7 additions & 2 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1791,13 +1791,18 @@ let X1 = Tuple{AlmostLU, Vector{T}} where T,
@test_broken I == actual
end

# issue #22787
# for now check that these don't stack overflow
let
# issue #22787
# for now check that these don't stack overflow
t = typeintersect(Tuple{Type{Q}, Q, Ref{Q}} where Q<:Ref,
Tuple{Type{S}, Union{Ref{S}, Ref{R}}, R} where R where S)
@test_broken t != Union{}
t = typeintersect(Tuple{Type{T}, T, Ref{T}} where T,
Tuple{Type{S}, Ref{S}, S} where S)
@test_broken t != Union{}

# issue #38279
t = typeintersect(Tuple{<:Array{T, N}, Val{T}} where {T<:Real, N},
Tuple{<:Array{T, N}, Val{<:AbstractString}} where {T<:Real, N})
@test t == Tuple{<:Array{Union{}, N}, Val{Union{}}} where N
end

0 comments on commit 2af16f9

Please sign in to comment.