Skip to content

[Proposal] Make Numeric Refine a new AdditiveArithmetic Protocol#942

Merged
lattner merged 5 commits intoswiftlang:masterfrom
rxwei:master
Nov 1, 2018
Merged

[Proposal] Make Numeric Refine a new AdditiveArithmetic Protocol#942
lattner merged 5 commits intoswiftlang:masterfrom
rxwei:master

Conversation

@rxwei
Copy link
Contributor

@rxwei rxwei commented Oct 31, 2018

@lattner lattner merged commit 171cc52 into swiftlang:master Nov 1, 2018

```swift
let x = Vector<Int>(...)
x * 1 // Ambiguous! Can be both `x * Vector(integerLiteral: 1)` and `x * (1 as Int)`.
Copy link
Member

@natecook1000 natecook1000 Nov 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants