[Proposal] Make Numeric Refine a new AdditiveArithmetic Protocol#942
Merged
lattner merged 5 commits intoswiftlang:masterfrom Nov 1, 2018
Merged
[Proposal] Make Numeric Refine a new AdditiveArithmetic Protocol#942lattner merged 5 commits intoswiftlang:masterfrom
lattner merged 5 commits intoswiftlang:masterfrom
Conversation
natecook1000
reviewed
Nov 1, 2018
|
|
||
| ```swift | ||
| let x = Vector<Int>(...) | ||
| x * 1 // Ambiguous! Can be both `x * Vector(integerLiteral: 1)` and `x * (1 as Int)`. |
Member
There was a problem hiding this comment.
I meant to note that this isn't ambiguous, since the type checker will always first try to use a literal's default type (Int for integer literals). If there's a use that supports that, the default wins. When there's nothing available using the default, then there's an ambiguity, so making this example use a Vector<Double> would be a better illustration. There's no precedence in that case between Vector<Double> and Vector<Double>.Scalar (i.e. Double), so there's an ambiguity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pitch thread: Make Numeric Refine a new AdditiveArithmetic Protocol