Skip to content

Commit ae20130

Browse files
authored
Merge pull request #20448 from JuliaLang/jb/20344
small change to type intersection that fixes #20344
2 parents 58b4f1a + 0388c5e commit ae20130

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/subtype.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ static jl_value_t *finish_unionall(jl_value_t *res, jl_varbinding_t *vb, jl_sten
11871187
// remove/replace/rewrap free occurrences of this var in the environment
11881188
jl_varbinding_t *btemp = e->vars;
11891189
while (btemp != NULL) {
1190-
if (jl_has_typevar(btemp->lb, vb->var)) {
1190+
if (jl_has_typevar(btemp->lb, vb->var) && vb->lb != (jl_value_t*)btemp->var) {
11911191
if (varval)
11921192
btemp->lb = jl_substitute_var(btemp->lb, vb->var, varval);
11931193
else if (btemp->lb == (jl_value_t*)vb->var)
@@ -1196,7 +1196,7 @@ static jl_value_t *finish_unionall(jl_value_t *res, jl_varbinding_t *vb, jl_sten
11961196
btemp->lb = jl_new_struct(jl_unionall_type, vb->var, btemp->lb);
11971197
assert((jl_value_t*)btemp->var != btemp->lb);
11981198
}
1199-
if (jl_has_typevar(btemp->ub, vb->var)) {
1199+
if (jl_has_typevar(btemp->ub, vb->var) && vb->ub != (jl_value_t*)btemp->var) {
12001200
if (varval)
12011201
btemp->ub = jl_substitute_var(btemp->ub, vb->var, varval);
12021202
else if (btemp->ub == (jl_value_t*)vb->var)

test/subtype.jl

+5
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,11 @@ function test_intersection()
807807
Union{Tuple{S,Array{Int64,1}},Tuple{S,Array{S,1}}} where S),
808808
Union{Tuple{Vector{Int64},Vector{Int64}},
809809
Tuple{Vector{T},Vector{T}} where T>:Vector})
810+
811+
# part of issue #20344
812+
@testintersect(Tuple{Type{Tuple{Vararg{T, N} where N}}, Tuple} where T,
813+
Tuple{Type{Tuple{Vararg{T, N}}} where N where T, Any},
814+
Tuple{Type{Tuple{}}, Tuple})
810815
end
811816

812817
function test_intersection_properties()

0 commit comments

Comments
 (0)