Skip to content
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

[SR-2199] Ambiguous use of operator '+' #44806

Open
krzyzanowskim opened this issue Jul 28, 2016 · 2 comments
Open

[SR-2199] Ambiguous use of operator '+' #44806

krzyzanowskim opened this issue Jul 28, 2016 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation

Comments

@krzyzanowskim
Copy link
Contributor

Previous ID SR-2199
Radar None
Original Reporter @krzyzanowskim
Type Bug
Environment

DEVELOPMENT-SNAPSHOT-2016-07-25-a

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI
Assignee None
Priority Medium

md5: 1fa6ee47be765a99180d02a5cfbaf8dc

relates to:

  • SR-1255 Binary operator '||' cannot be applied to two 'Bool' operands.

Issue Description:

There is ambiguity of '+' operator as shown below. I'm not sure what cause it (Xcode not helping) though it may be due to Aritmetic (or SignedNumber).

let a: UInt = 1
let b: Int = 1
let c = a + b // Error: Ambiguous use of operator '+'

let aa: UInt32 = 1
let bb: UInt = 1
let cc = aa + bb // Error: Binary operator '+' cannot be applied to operands of type 'UInt32' and 'UInt'
@belkadan
Copy link
Contributor

This has never been allowed*, but we could probably produce better diagnostics.

* We had an unfortunate case in the past where the integer types being ForwardIndexes with a Distance type of 'Int' caused + to be accepted on mixed types. We attempted to defend against that by making it ambiguous, but the Swift 3 collection model fixes it altogether by moving the "advance" method to the collection.

@Dante-Broggi
Copy link
Contributor

I think this should be resolved as expected behavior.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation
Projects
None yet
Development

No branches or pull requests

3 participants