Skip to content

Commit

Permalink
Merge pull request #21012 from JuliaLang/jb/fix20998
Browse files Browse the repository at this point in the history
fix #20998
  • Loading branch information
JeffBezanson authored Mar 14, 2017
2 parents 58ed252 + 6fb2c67 commit 64409a0
Show file tree
Hide file tree
Showing 2 changed files with 6 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 @@ -1292,9 +1292,9 @@ static jl_value_t *finish_unionall(jl_value_t *res, jl_varbinding_t *vb, jl_sten

if (vb->right && e->envidx < e->envsz) {
jl_value_t *oldval = e->envout[e->envidx];
if (!varval)
if (!varval || (!is_leaf_bound(varval) && !var_occurs_invariant(res, vb->var, 0)))
e->envout[e->envidx] = (jl_value_t*)vb->var;
else if (!oldval || !jl_is_typevar(oldval) || !jl_is_long(varval))
else if (!(oldval && jl_is_typevar(oldval) && jl_is_long(varval)))
e->envout[e->envidx] = varval;
}

Expand Down
4 changes: 4 additions & 0 deletions test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,10 @@ function test_intersection()
@testintersect(Tuple{Ref{Pair{p2,T2}}, Pair{p1,Pair}} where T2 where p2 where p1,
Tuple{Ref{Pair{p3,T3}}, Pair{p3}} where T3 where p3,
Tuple{Ref{Pair{p1,T2}}, Pair{p1,Pair}} where T2 where p1)

# issue #20998
_, E = intersection_env(Tuple{Int,Any,Any}, Tuple{T,T,S} where {T,S})
@test length(E) == 2 && E[1] == Int && isa(E[2], TypeVar)
end

function test_intersection_properties()
Expand Down

0 comments on commit 64409a0

Please sign in to comment.