Skip to content

potential for better type inference with Vararg #37316

Closed
@simeonschaub

Description

@simeonschaub

Since for example Vararg{Any,Int} throws an error during construction, would it be possible to take advantage of the fact that the N parameter in a Vararg is always an Int in type inference? It would be nice if the following inferred more precisely:

julia> f(::NTuple{N}) where {N} = N
f (generic function with 1 method)

julia> code_warntype(f, Tuple{Tuple})
Variables
  #self#::Core.Compiler.Const(f, false)
  #unused#::Tuple{Vararg{T,N}} where T where N

Body::Any
1return $(Expr(:static_parameter, 1))

Sorry if there is an issue about this already, but I couldn't find one.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions