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-12863] Incorrect error when using dynamic member lookup with enum #55309

Closed
bjhomer opened this issue May 22, 2020 · 4 comments
Closed

[SR-12863] Incorrect error when using dynamic member lookup with enum #55309

bjhomer opened this issue May 22, 2020 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software type checker Area → compiler: Semantic analysis

Comments

@bjhomer
Copy link
Contributor

bjhomer commented May 22, 2020

Previous ID SR-12863
Radar rdar://problem/63551048
Original Reporter @bjhomer
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 11.5 (Swift 5.2)

Using the Swift 5.3 dev snapshot from 5/19/2020, the compiler crashes instead.

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

md5: 151dce9b2c4b1b25159ced57c7792ed6

Issue Description:

The following code produces an incorrect error:

enum ButtonPropertiesCases {
    case backgroundColor  // Swift 5.2: "Error: enums must not contain stored properties."
    case font
}


@dynamicMemberLookup
class ButtonProperties {
    subscript(dynamicMember key: KeyPath<ButtonPropertiesCases.Type, ButtonPropertiesCases>) -> Bool {
        get { return false }
        set(newValue) { /* do nothing for now */ }
    }
}


let buttonProps = ButtonProperties()
let x = buttonProps.backgroundColor

Simple Xcode project attached

@theblixguy
Copy link
Collaborator

Fix: #31969

@theblixguy
Copy link
Collaborator

Fixed on master by #31969 and cherry-picked to 5.3: #31972

@bjhomer Please verify using the next available snapshot!

@bjhomer
Copy link
Contributor Author

bjhomer commented May 22, 2020

Thanks for the quick turnaround!

@xedin
Copy link
Member

xedin commented May 22, 2020

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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 crash Bug: A crash, i.e., an abnormal termination of software type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants