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-12705] Wrong diagnostic when method called with wrong argument labels on result of operator #55149

Closed
belkadan opened this issue Apr 30, 2020 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@belkadan
Copy link
Contributor

Previous ID SR-12705
Radar rdar://problem/62894033
Original Reporter @belkadan
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee @belkadan
Priority Medium

md5: 87e74907a6ae795bb6224a8366804a56

Issue Description:

func bindToInt(
  _ base: UnsafeMutableRawPointer,
  at offset: Int
) -> UnsafeMutablePointer<Int> {
  let result = (base + offset).bindMemory(to: Int.self, count: 1)
  return result
}
<stdin>:5:17: error: cannot convert value of type 'UnsafeMutableRawPointer' to expected argument type 'Int'
  let result = (base + offset).bindMemory(to: Int.self, count: 1)
                ^
<stdin>:5:32: error: value of type 'Int' has no member 'bindMemory'
  let result = (base + offset).bindMemory(to: Int.self, count: 1)
               ~~~~~~~~~~~~~~~ ^~~~~~~~~~

The correct error is shown if the offsetting is extracted into a temporary: "incorrect argument label in call (have 'to:count:', expected 'to:capacity:')"

@beccadax
Copy link
Contributor

beccadax commented May 5, 2020

@swift-ci create

@xedin
Copy link
Member

xedin commented Apr 2, 2021

Looks like this has been fixed on main branch:

 error: incorrect argument label in call (have 'to:count:', expected 'to:capacity:')
  let result = (base + offset).bindMemory(to: Int.self, count: 1)
                                         ^              ~~~~~
                                                        capacity

@belkadan Please use the latest main branch snapshot to verify and close.

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants