Open
Description
Currently, you can construct NTuples for any iterable with more than N elements:
julia> NTuple{1}("hello")
('h',)
julia> NTuple{3}(1:5)
(1, 2, 3)
This strikes me as problematic, and an easy way of getting into trouble. If the user tries to create NTuple from something with more than N elements, they probably made a mistake. It would be much nicer if it behaved like:
julia> NTuple{3}(1:5)
ERROR: ArgumentError: too many elements for tuple type Tuple{T} where T
Stacktrace:
[1] _totuple_err(T::Any)
@ Base ./tuple.jl:309
(or similar). In practice, this could be done by simply verifying that the iterator returns nothing
before returning the tuple.
This change is breaking, but it may be worth considering for a future, breaking release, but perhaps the issue can be solved in a non-breaking way somehow.