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-5069] Error referring to enum case in a dot-referenced function call ending with a closure. #47645

Closed
michelf opened this issue Jun 1, 2017 · 3 comments
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

@michelf
Copy link

michelf commented Jun 1, 2017

Previous ID SR-5069
Radar None
Original Reporter @michelf
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 5f83b01c4a5465659cec4d38a86e1f2e

Issue Description:

The following code probably shouldn't create an error. But it does.

enum E {
    case begin
    case end
}
struct Z {
    var e: E
    static func create(_ e: E, f: (inout Z) -> ()) -> Z {
        return Z(e: e)
    }
}
let z: Z = .create(.begin) { $0.e = .end }

Playground execution failed: error: MyPlayground.playground:5:21: error: enum element 'begin' cannot be referenced as an instance member
let z: Z = .create(.begin) { $0.e = .end }
^

Tested with Xcode 8.3.2 both with the built-in toolchain as well as with the Swift 4.0 snapshot 2017-05-24. Fully qualifying the function name works as a workaround:

let z = Z.create(.begin) { $0.e = .end }

@michelf
Copy link
Author

michelf commented Jun 1, 2017

Adding a second dummy statement in the closure can also fix this:

let z: Z = .create(.begin) { $0.e = .end; $0.e = .begin }

@swift-ci
Copy link
Collaborator

swift-ci commented Aug 4, 2018

Comment by Tim (JIRA)

This appears to have been fixed in more recent Swift versions.

@michelf
Copy link
Author

michelf commented Aug 4, 2018

Indeed, it works now.

@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

2 participants