Skip to content

Commit

Permalink
fix #34170, assertion failure with obvious_subtype (#38904)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Dec 16, 2020
1 parent 9e52bdf commit 8f6432e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -2549,7 +2549,7 @@ static jl_value_t *finish_unionall(jl_value_t *res JL_MAYBE_UNROOTED, jl_varbind
res = jl_substitute_var(res, vb->var, (jl_value_t*)newvar);
varval = (jl_value_t*)newvar;
if (wrap)
res = jl_new_struct(jl_unionall_type, (jl_tvar_t*)newvar, res);
res = jl_type_unionall((jl_tvar_t*)newvar, res);
}
}

Expand All @@ -2558,7 +2558,7 @@ static jl_value_t *finish_unionall(jl_value_t *res JL_MAYBE_UNROOTED, jl_varbind
for(i=0; i < jl_array_len(vb->innervars); i++) {
jl_tvar_t *var = (jl_tvar_t*)jl_array_ptr_ref(vb->innervars, i);
if (jl_has_typevar(res, var))
res = jl_new_struct(jl_unionall_type, (jl_tvar_t*)var, res);
res = jl_type_unionall((jl_tvar_t*)var, res);
}
}

Expand Down
9 changes: 9 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1845,3 +1845,12 @@ let A = Tuple{T, Ref{T}, T} where {T},
@test_broken I <: A
@test_broken I <: B
end

# issue #34170
let A = Tuple{Type{T} where T<:Ref, Ref, Union{T, Union{Ref{T}, T}} where T<:Ref},
B = Tuple{Type{T}, Ref{T}, Union{Int, Ref{T}, T}} where T
I = typeintersect(A,B)
# this was a case where <: disagreed with === (due to a badly-normalized type)
@test I == typeintersect(A,B)
@test I == Tuple{Type{T}, Ref{T}, Union{Ref{T}, T}} where T<:Ref
end

0 comments on commit 8f6432e

Please sign in to comment.