Navigation Menu

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-2208] Binary operator '/' cannot be applied to two 'Int' operands #44815

Closed
krzyzanowskim opened this issue Jul 29, 2016 · 3 comments
Closed
Assignees
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 regression swift 3.0 type checker Area → compiler: Semantic analysis

Comments

@krzyzanowskim
Copy link
Contributor

Previous ID SR-2208
Radar rdar://problem/26917664
Original Reporter @krzyzanowskim
Type Bug
Status Resolved
Resolution Done
Environment

DEVELOPMENT-SNAPSHOT-2016-07-28-a

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, 3.0Regression, DiagnosticsQoI, TypeChecker
Assignee @krzyzanowskim
Priority Medium

md5: 125d123b1c15a16f235b09bde4d474ad

is duplicated by:

  • SR-2368 Poor error message when doing math on Ints where a Double is expected.
  • SR-3049 Invalid use of "binary operator '&' cannot be applied to two 'Int' operands"
  • SR-3198 Misleading compiler error when defining comparison operator with wrong return type

relates to:

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

Issue Description:

When passing operation as parameter to function that expects single value, type checked ❓ is confused about passing value type and report error message: Expected an argument list of type '(UInt, UInt)' while for real, expected argument is single value of UInt (in example below)

struct Booo {
    func test(value: UInt) {}
}

func test() {
    let bo = Booo()
    let a: Int = 1
    let b: Int = 2
    bo.test(value: a / b) // Error: Binary operator '/' cannot be applied to two 'Int' operands
                                    // Expected an argument list of type '(UInt, UInt)'
}

with intermediate variable, error message is more accurate:

let result = a / b
bo.test(value: result) // Error: Cannot convert value of type 'Int' to expected argument type 'UInt'

and finally, it's working:

let result = a / b
bo.test(value: UInt(result)) // OK
@belkadan
Copy link
Contributor

Possibly the same root cause as SR-2199. Thanks for reporting these, Marcin!

@rudkx
Copy link
Member

rudkx commented Jul 29, 2016

Assigning to Chris since he has a related bug for this.

@rudkx
Copy link
Member

rudkx commented Jan 6, 2017

Fixed a while ago in dd01b7e.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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 regression swift 3.0 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants