-
-
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
potential for better type inference with Vararg #37316
Labels
compiler:inference
Type inference
Comments
Yes, it looks like we should add this. |
Looks like we still don't infer this on nightly: julia> f(::NTuple{N}) where {N} = N
f (generic function with 1 method)
julia> code_warntype(f, Tuple{Tuple})
Variables
#self#::Core.Const(f)
#unused#::Tuple{Vararg{T, N}} where T where N
Body::Any
1 ─ return $(Expr(:static_parameter, 1)) |
Ah, but it does infer now if the Tuple has a concrete eltype: julia> f(::NTuple{N}) where {N} = N
f (generic function with 1 method)
julia> code_warntype(f, Tuple{Tuple{Vararg{Int}}})
Variables
#self#::Core.Const(f)
#unused#::Tuple{Vararg{Int64}}
Body::Int64
1 ─ return $(Expr(:static_parameter, 1)) |
Fixed by #51449. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since for example
Vararg{Any,Int}
throws an error during construction, would it be possible to take advantage of the fact that theN
parameter in aVararg
is always anInt
in type inference? It would be nice if the following inferred more precisely:Sorry if there is an issue about this already, but I couldn't find one.
The text was updated successfully, but these errors were encountered: