diff --git a/src/subtype.c b/src/subtype.c index 8eb6313954263..ec7d7a8e4b73f 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -1038,6 +1038,7 @@ static int forall_exists_subtype(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, in int set = e->Lunions.more; if (!sub || !set) break; + save_env(e, &saved, &se); for (int i = set; i <= lastset; i++) statestack_set(&e->Lunions, i, 0); lastset = set - 1; diff --git a/test/subtype.jl b/test/subtype.jl index 69150ee6fb34c..43474dd716d76 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -1259,3 +1259,17 @@ end let (t, e) = intersection_env(Tuple{Union{Int,Int8}}, Tuple{T} where T) @test e[1] isa TypeVar end + +# issue #26654 +@test !(Ref{Union{Int64, Ref{Number}}} <: Ref{Union{Ref{T}, T}} where T) +@test !(Ref{Union{Int64, Val{Number}}} <: Ref{Union{Val{T}, T}} where T) +@test !(Ref{Union{Ref{Number}, Int64}} <: Ref{Union{Ref{T}, T}} where T) +@test !(Ref{Union{Val{Number}, Int64}} <: Ref{Union{Val{T}, T}} where T) + +# issue #26180 +@test !(Ref{Union{Ref{Int64}, Ref{Number}}} <: Ref{Ref{T}} where T) +@test !(Ref{Union{Ref{Int64}, Ref{Number}}} <: Ref{Union{Ref{T}, Ref{T}}} where T) + +# issue #25240, #26405 +f26405(::Type{T}) where {T<:Union{Integer, Missing}} = T +@test f26405(Union{Missing, Int}) == Union{Missing, Int}