julia> @code_warntype NTuple{3}([1,2,3])
Variables
#self#::Type{Tuple{T, T, T} where T}
itr::Vector{Int64}
Body::Tuple{Int64, Int64, Int64, Vararg{Any}}
1 ─ %1 = Base._totuple($(Expr(:static_parameter, 1)), itr)::Tuple{Int64, Int64, Int64, Vararg{Any}}
└── return %1
The inferred type is Tuple{Int64, Int64, Int64, Vararg{Any}}
, but shouldn’t the number of elements be known? Strangely the following is type stable:
julia> @code_warntype NTuple{3,Int}([1,2,3])
Variables
#self#::Core.Const(Tuple{Int64, Int64, Int64})
itr::Vector{Int64}
Body::Tuple{Int64, Int64, Int64}
1 ─ %1 = Base._totuple($(Expr(:static_parameter, 1)), itr)::Tuple{Int64, Int64, Int64}
└── return %1