Skip to content

Commit 8f6432e

Browse files
authored
fix #34170, assertion failure with obvious_subtype (#38904)
1 parent 9e52bdf commit 8f6432e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/subtype.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,7 +2549,7 @@ static jl_value_t *finish_unionall(jl_value_t *res JL_MAYBE_UNROOTED, jl_varbind
25492549
res = jl_substitute_var(res, vb->var, (jl_value_t*)newvar);
25502550
varval = (jl_value_t*)newvar;
25512551
if (wrap)
2552-
res = jl_new_struct(jl_unionall_type, (jl_tvar_t*)newvar, res);
2552+
res = jl_type_unionall((jl_tvar_t*)newvar, res);
25532553
}
25542554
}
25552555

@@ -2558,7 +2558,7 @@ static jl_value_t *finish_unionall(jl_value_t *res JL_MAYBE_UNROOTED, jl_varbind
25582558
for(i=0; i < jl_array_len(vb->innervars); i++) {
25592559
jl_tvar_t *var = (jl_tvar_t*)jl_array_ptr_ref(vb->innervars, i);
25602560
if (jl_has_typevar(res, var))
2561-
res = jl_new_struct(jl_unionall_type, (jl_tvar_t*)var, res);
2561+
res = jl_type_unionall((jl_tvar_t*)var, res);
25622562
}
25632563
}
25642564

test/subtype.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,3 +1845,12 @@ let A = Tuple{T, Ref{T}, T} where {T},
18451845
@test_broken I <: A
18461846
@test_broken I <: B
18471847
end
1848+
1849+
# issue #34170
1850+
let A = Tuple{Type{T} where T<:Ref, Ref, Union{T, Union{Ref{T}, T}} where T<:Ref},
1851+
B = Tuple{Type{T}, Ref{T}, Union{Int, Ref{T}, T}} where T
1852+
I = typeintersect(A,B)
1853+
# this was a case where <: disagreed with === (due to a badly-normalized type)
1854+
@test I == typeintersect(A,B)
1855+
@test I == Tuple{Type{T}, Ref{T}, Union{Ref{T}, T}} where T<:Ref
1856+
end

0 commit comments

Comments
 (0)