That's https://github.com/JuliaLang/julia/pull/11242. Another common workaround is a generated function (but the wrapper function is better if you don't need other generated functionality):
@generated function f(x...) N = length(x) :(Array{Int, $N}) end On Tuesday, April 19, 2016 at 8:52:17 AM UTC-4, Milan Bouchet-Valat wrote: > > Hi! > > I'm looking for the recommended way of getting type inference to > determine the number of elements passed via varargs. > > I guess a code snippet is better than a thousand words: in the > following function, the type of a isn't inferred correctly. > > function f(x...) > N = length(x) > a = Array{Int, N}() > # ... > end > > Using a wrapper function fixes the type instability: > > g(x...) = g(x) > function g{N}(x::NTuple{N}) > a = Array{Int, N}() > # > ... > end > > Is there a better solution than this workaround? > > > Regards >