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-11496] Enum with same name/different number of associated values: allowed, but crashes at runtime #53897

Open
swift-ci opened this issue Sep 20, 2019 · 1 comment
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-11496
Radar None
Original Reporter voxar (JIRA User)
Type Bug
Environment

Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)

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

md5: fe53c9c5e3f114a14ba0cbf8d0edd311

relates to:

  • SR-11159 Typechecker crash on overloaded enum case

Issue Description:

enum Foo {
    case bar(Int)
    case bar(Int, Int)
}

// works
switch Foo.bar(1, 2) {
case let .bar(a): print("bar", a)
}

// crashes as runtime
switch Foo.bar(1) {
case let .bar(a): print("bar", a)
}

❌ Fatal error: unexpected enum case while switching on value of type 'Bar'

@belkadan
Copy link
Contributor

Likely also handled by AndrewLitteken (JIRA User)'s work in SR-11159. (By rejecting the code at compile time, since all cases are not matched.)

@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

2 participants