julia
8de80bdf - inference: restrict type of type parameter from `Vararg` (#51449)

Commit
2 years ago
inference: restrict type of type parameter from `Vararg` (#51449) Inference has been able to restrict type of `Vararg` type parameter `N` to `Int` for cases like `func(..., ::Vararg{T,N}) where {T,N}`, but this refinement was not available for signatures like `func(::Tuple{Vararg{T,N}}) where {T,N}`. This commit allows the later case to be inferred as well. Now the following kind of case will be inferred, e.g.: ```julia julia> function sub2ind_gen_fallback(dims::NTuple{N,Int}, I) where N # N is knonw to be ::Int ind = I[N] - 1 for i = (N - 1):-1:1 ind = I[i] - 1 + dims[i]*ind end return ind + 1 end; julia> only(Base.return_types(sub2ind_gen_fallback, (NTuple,Tuple{Vararg{Int}}))) Int64 ```
Author
Parents
Loading