-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add another tuple subtyping fast path #34065
Conversation
This handles cases like `Type{Tuple{}} <: Type{Tuple{Vararg{_,N} where N}}`, i.e. where a fixed-length tuple type cannot ever equal an indefinite-length tuple type.
if (!jl_is_tuple_type(x)) | ||
return 0; | ||
size_t n = jl_nparams(x); | ||
return n > 0 && jl_vararg_kind(jl_tparam(x, n-1)) == JL_VARARG_UNBOUND; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return n > 0 && jl_vararg_kind(jl_tparam(x, n-1)) == JL_VARARG_UNBOUND; | |
return n > 0 && jl_vararg_kind(jl_tparam(x, n-1)) == JL_VARARG_UNBOUND && !var_occurs_inside(x, jl_unwrap_vararg(jl_tparam(x, n-1)) , 0, 1); |
(from #32742)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is needed, since we can make this conclusion based only on length.
Could/should we use the code from Lines 1645 to 1685 in 7794574
|
Ah, it's tricky. The code in obvious_subtype is already extremely close to handling this, and the only reason it doesn't is the free variables check here: Line 1713 in 7794574
This is a lucky case where the fast path works despite free variables, so it's hard to incorporate in this structure. obvious_subtype also updates a few local variables in there, so it's hard to refactor. |
This handles cases like `Type{<:Tuple{A}} <: Type{Tuple{Vararg{_,N} where N}}`, i.e. where a fixed-length tuple type cannot ever equal an indefinite-length tuple type.
This handles cases like `Type{<:Tuple{A}} <: Type{Tuple{Vararg{_,N} where N}}`, i.e. where a fixed-length tuple type cannot ever equal an indefinite-length tuple type.
This handles cases like
Type{Tuple{}} <: Type{Tuple{Vararg{_,N} where N}}
, i.e. where a fixed-length tuple type cannot ever equal an indefinite-length tuple type.This fixes an issue reported offline; see the added strings test for example code. In 1.2 the code worked fine, but it hangs in subtyping in 1.3. The change seems to be due to a combination of new
*
methods forRegex
plus other internal changes (ml_matches_visitor
being more aggressive at avoiding method matches shadowed by previous matches).