-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disallow construction of NTuple from > N elements #40495
Comments
Related: #37132 |
This is only "breaking" in the sense that fixing it could break some user code that depends on the current, buggy, behavior; however the buggy behavior was never documented. So I think the buggy behavior is not supported and I don't think that fixing it should necessarily be considered as breaking. Does Julia have some backwards compatibility promise document? Perhaps such a document would have answers to questions like this one, if it exists? |
Make tuple construction from overlong iterators throw instead of truncating the input iterator. Fixes JuliaLang#40495 Fixes JuliaLang#52657 Make tuple construction from known constant-length iterators inferrable and prevent allocation. Fixes JuliaLang#52993 Compute more accurate tuple element types in many cases using `typeintersect`, with a fallback to the old behavior. This prevents some cases of `convert` throwing due to ambiguity. Instead of just calling `typeintersect` on the tuple types, do `typeintersect` again once `fieldtype` computes the element type. Fixes JuliaLang#53181 Separate the tuple construction from tuple element conversion, allowing dropping the `tuple_type_tail` dependency. Fixes JuliaLang#53182 Trying to construct a tuple from an infinite iterator now results in an `ArgumentError` instead of in a `MethodError`.
Make tuple construction from overlong iterators throw instead of truncating the input iterator. Fixes JuliaLang#40495 Fixes JuliaLang#52657 Make tuple construction from known constant-length iterators inferrable and prevent allocation. Fixes JuliaLang#52993 Compute more accurate tuple element types in many cases using `typeintersect`, with a fallback to the old behavior. This prevents some cases of `convert` throwing due to ambiguity. Instead of just calling `typeintersect` on the tuple types, do `typeintersect` again once `fieldtype` computes the element type. Fixes JuliaLang#53181 Separate the tuple construction from tuple element conversion, allowing dropping the `tuple_type_tail` dependency. Fixes JuliaLang#53182 Trying to construct a tuple from an infinite iterator now throws an `ArgumentError` instead of succeeding or throwing a `MethodError`.
Make tuple construction from overlong iterators throw instead of truncating the input iterator. Fixes JuliaLang#40495 Fixes JuliaLang#52657 Make tuple construction from known constant-length iterators inferrable and prevent allocation. Fixes JuliaLang#52993 Compute more accurate tuple element types in many cases using `typeintersect`, with a fallback to the old behavior. This prevents some cases of `convert` throwing due to ambiguity. Instead of just calling `typeintersect` on the tuple types, do `typeintersect` again once `fieldtype` computes the element type. Fixes JuliaLang#53181 Separate the tuple construction from tuple element conversion, allowing dropping the `tuple_type_tail` dependency. Fixes JuliaLang#53182 Trying to construct a tuple from an infinite iterator now throws an `ArgumentError` instead of succeeding or throwing a `MethodError`.
Make tuple construction from overlong iterators throw instead of truncating the input iterator. Fixes JuliaLang#40495 Fixes JuliaLang#52657 Make tuple construction from known constant-length iterators inferrable and prevent allocation. Fixes JuliaLang#52993 Compute more accurate tuple element types in many cases using `typeintersect`, with a fallback to the old behavior. This prevents some cases of `convert` throwing due to ambiguity. Instead of just calling `typeintersect` on the tuple types, do `typeintersect` again once `fieldtype` computes the element type. Fixes JuliaLang#53181 Separate the tuple construction from tuple element conversion, allowing dropping the `tuple_type_tail` dependency. Fixes JuliaLang#53182 Trying to construct a tuple from an infinite iterator now throws an `ArgumentError` instead of succeeding or throwing a `MethodError`.
Make tuple construction from overlong iterators throw instead of truncating the input iterator. Trying to construct a tuple from an infinite iterator now throws an `ArgumentError` instead of succeeding or throwing a `MethodError`. Fixes JuliaLang#40495 Fixes JuliaLang#52657 Make tuple construction from known constant-length iterators inferrable and prevent allocation. Fixes JuliaLang#52993 Compute more accurate tuple element types in many cases using `typeintersect`, with a fallback to the old behavior. This prevents some cases of `convert` throwing due to ambiguity. Instead of just calling `typeintersect` on the tuple types, do `typeintersect` again once `fieldtype` computes the element type. Fixes JuliaLang#53181 Separate the tuple construction from tuple element conversion, allowing dropping the `tuple_type_tail` dependency. Fixes JuliaLang#53182
Make tuple construction from overlong iterators throw instead of truncating the input iterator. Trying to construct a tuple from an infinite iterator now throws an `ArgumentError` instead of succeeding or throwing a `MethodError`. Fixes JuliaLang#40495 Fixes JuliaLang#52657 Make tuple construction from known constant-length iterators inferrable and prevent allocation. Fixes JuliaLang#52993 Compute more accurate tuple element types in many cases using `typeintersect`, with a fallback to the old behavior. This prevents some cases of `convert` throwing due to ambiguity. Instead of just calling `typeintersect` on the tuple types, do `typeintersect` again once `fieldtype` computes the element type. Fixes JuliaLang#53181 Separate the tuple construction from tuple element conversion, allowing dropping the `tuple_type_tail` dependency. Fixes JuliaLang#53182
Currently, you can construct NTuples for any iterable with more than N elements:
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:
(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.
The text was updated successfully, but these errors were encountered: