Skip to content

Commit

Permalink
Disallow more circulation once we set lb==ub.
Browse files Browse the repository at this point in the history
close JuliaLang#26487.
This should be valid as we never set `X<:Y<:X` (assuming `Y` is outer var).
  • Loading branch information
N5N3 committed Jan 11, 2023
1 parent 46b6c9a commit 3bed1f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -3249,7 +3249,13 @@ static jl_value_t *intersect(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int pa
return jl_bottom_type;
}
int ccheck;
if (yub == xub ||
if (xlb == xub && ylb == yub && jl_has_typevar(xlb, y) && jl_has_typevar(ylb, x)) {
// specical case for e.g.
// 1) Val{Y}<:X<:Val{Y} && Val{X}<:Y<:Val{X}
// 2) Y<:X<:Y && Val{X}<:Y<:Val{X} => Val{Y}<:Y<:Val{Y}
ccheck = 0;
}
else if (yub == xub ||
(subtype_by_bounds(xlb, yub, e) && subtype_by_bounds(ylb, xub, e))) {
ccheck = 1;
}
Expand Down
8 changes: 5 additions & 3 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,11 @@ end
Tuple{Type{Vector{Union{T, R}}}, Matrix{Union{T, R}}} where {R<:Real, T<:Real},
Union{})

#issue 26487
@testintersect(Tuple{Type{Tuple{T,Val{T}}}, Val{T}} where T,
Tuple{Type{Tuple{Val{T},T}}, Val{T}} where T,
Union{})

@testset "known subtype/intersect issue" begin
#issue 45874
# Causes a hang due to jl_critical_error calling back into malloc...
Expand Down Expand Up @@ -2384,9 +2389,6 @@ end
#issue 33137
@test_broken (Tuple{Q,Int} where Q<:Int) <: Tuple{T,T} where T

#issue 26487
@test_broken typeintersect(Tuple{Type{Tuple{T,Val{T}}}, Val{T}} where T, Tuple{Type{Tuple{Val{T},T}}, Val{T}} where T) <: Any

# issue 24333
@test_broken (Type{Union{Ref,Cvoid}} <: Type{Union{T,Cvoid}} where T)

Expand Down

0 comments on commit 3bed1f1

Please sign in to comment.