Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widen diagonal var during Type unwrapping in instanceof_tfunc #52228

Merged
merged 5 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -4439,7 +4439,7 @@ static jl_value_t *insert_nondiagonal(jl_value_t *type, jl_varbinding_t *troot,
newa = insert_nondiagonal(a, troot, widen2ub);
newb = insert_nondiagonal(b, troot, widen2ub);
if (newa != a || newb != b)
type = (jl_value_t *)jl_new_struct(jl_uniontype_type, newa, newb);
type = simple_union(newa, newb);
JL_GC_POP();
}
else if (jl_is_vararg(type)) {
Expand Down Expand Up @@ -4499,7 +4499,8 @@ static jl_value_t *widen_diagonal(jl_value_t *t, jl_unionall_t *u, jl_varbinding
if (vb.innervars != NULL) {
for (size_t i = 0; i < jl_array_nrows(vb.innervars); i++) {
jl_tvar_t *var = (jl_tvar_t*)jl_array_ptr_ref(vb.innervars, i);
nt = jl_type_unionall(var, nt);
if (jl_has_typevar(nt, var))
nt = jl_type_unionall(var, nt);
N5N3 marked this conversation as resolved.
Show resolved Hide resolved
N5N3 marked this conversation as resolved.
Show resolved Hide resolved
}
}
JL_GC_POP();
Expand Down
3 changes: 2 additions & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8067,5 +8067,6 @@ let widen_diagonal(x::UnionAll) = Base.rewrap_unionall(Base.widen_diagonal(Base.
@test Tuple{Int,Float64} <: widen_diagonal(Tuple{T,T} where {T})
@test Tuple{Real,Int,Float64} <: widen_diagonal(Tuple{S,Vararg{T}} where {S, T<:S})
@test Tuple{Int,Int,Float64,Float64} <: widen_diagonal(Tuple{S,S,Vararg{T}} where {S, T<:S})
@test Union{Tuple{T}, Tuple{T,Int}} where {T} == widen_diagonal(Union{Tuple{T}, Tuple{T,Int}} where {T})
@test Union{Tuple{T}, Tuple{T,Int}} where {T} === widen_diagonal(Union{Tuple{T}, Tuple{T,Int}} where {T})
@test Tuple === widen_diagonal(Union{Tuple{Vararg{S}}, Tuple{Vararg{T}}} where {S, T})
end
Loading