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-15768] Unexpected behavior using an enum with associated values #58045

Open
swift-ci opened this issue Jan 24, 2022 · 0 comments
Open

[SR-15768] Unexpected behavior using an enum with associated values #58045

swift-ci opened this issue Jan 24, 2022 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-15768
Radar None
Original Reporter FunnyItWorkedLastTime (JIRA User)
Type Bug
Environment

Reproduced in Xcode 13.2.1 and Xcode 13.1

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 90042d7a0dc9ccb216eb19873e3d6a1b

Issue Description:

I have run into an issue where the compiler is emitting the wrong value for an enum case at a call-site which in turn causes unexpected behaviour downstream when the value is pattern matched.

I have been able to reproduce with this trivial example:

import SwiftUI

enum Foo {
    case one
    case two(ScenePhase)
    case three
    case four(Bool)
    case five
    case six
    case seven
}

print(Foo.seven)     // prints "one"

I have also observed that the issue goes away when:

  • there are six cases only and not seven

  • the ScenePhase payload is replaced with a different type such as String

  • the Bool payload is removed so there is only a single associated type of ScenePhase

Others have observed this may be happening when using associated values that are non-frozen resilient enum types, see discussion here.

@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
Projects
None yet
Development

No branches or pull requests

1 participant