Skip to content

Commit b745293

Browse files
committed
Fix intersection bug caused by intvalued clean.
After e528b30, intersection would increase `N`‘s `occurs_inv` when compare `Vararg{Any}` and `Vararg{Any,N}` for reintersection hint. Here we just need to check if `ylv` is unbounded.
1 parent f8c6be4 commit b745293

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/subtype.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,9 @@ static int subtype_tuple_varargs(
10691069
}
10701070

10711071
if (ylv) {
1072-
if (ylv->depth0 != e->invdepth || ylv->occurs_inv)
1072+
if (ylv->depth0 != e->invdepth ||
1073+
ylv->lb != jl_bottom_type ||
1074+
ylv->ub != (jl_value_t *)jl_any_type)
10731075
return 0;
10741076
ylv->intvalued = 1;
10751077
}
@@ -2518,6 +2520,7 @@ static int check_unsat_bound(jl_value_t *t, jl_tvar_t *v, jl_stenv_t *e) JL_NOTS
25182520
return 0;
25192521
}
25202522

2523+
//TODO: This doesn't work for nested `Tuple`.
25212524
static int has_free_vararg_length(jl_value_t *a, jl_stenv_t *e) {
25222525
if (jl_is_unionall(a))
25232526
a = jl_unwrap_unionall(a);

test/subtype.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,6 +2218,12 @@ end
22182218
# Example from pr#39098
22192219
@testintersect(NTuple, Tuple{Any,Vararg}, Tuple{T, Vararg{T}} where {T})
22202220

2221+
let S = Val{T} where T<:Tuple{Tuple{Any, Vararg{Any}}}
2222+
T = Val{Tuple{Tuple{Vararg{Any, N}}}} where {N}
2223+
@testintersect(S, T, !Union{})
2224+
@test_broken typeintersect(S, T) != Val{Tuple{Tuple{Any, Vararg{Any}}}}
2225+
end
2226+
22212227
let A = Pair{NTuple{N, Int}, Val{N}} where N,
22222228
Bs = (Pair{<:Tuple{Int, Vararg{Int}}, <:Val},
22232229
Pair{Tuple{Int, Vararg{Int,N1}}, Val{N2}} where {N1,N2})

0 commit comments

Comments
 (0)