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-2501] Confusing error message about inout argument #45106

Open
swift-ci opened this issue Aug 27, 2016 · 1 comment
Open

[SR-2501] Confusing error message about inout argument #45106

swift-ci opened this issue Aug 27, 2016 · 1 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 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2501
Radar None
Original Reporter rnikander (JIRA User)
Type Bug
Environment

Xcode 8, beta 6, Swift 3

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

md5: fc534b72d2c88f282cb53409cbf355b2

relates to:

  • SR-7543 diagnostics behave incorrectly when passing parameter as inout argument in closure

Issue Description:

The following code compiles and runs:

struct A {
    var x: Int
}
var a = A(x: 123)
let result = withUnsafePointer(to: &a) {
    print("ptr is \($0)")
    // return 1
}
print("result is \(result)")

But, if you uncomment that return 1 line, the compile fails. It highlights the &a and says: Cannot pass immutable value of type 'inout A' as inout argument.

It seems like the type checking failed and produced a misleading error message.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Oct 5, 2016

Comment by Christopher Hatton (JIRA)

I got caught out by this thoroughly misleading error message as well! Looking forward to a fix.

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

No branches or pull requests

1 participant