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-11357] Weird behavior when defining enum cases with the same name #53758

Open
swift-ci opened this issue Aug 22, 2019 · 3 comments
Open

[SR-11357] Weird behavior when defining enum cases with the same name #53758

swift-ci opened this issue Aug 22, 2019 · 3 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-11357
Radar None
Original Reporter apaszke (JIRA User)
Type Bug
Environment

Apple Swift version 5.1 (swiftlang-1100.0.257.2 clang-1100.0.31.3)

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

md5: bc35ebcdfade60a2991e2f8249f3b888

relates to:

  • SR-11159 Typechecker crash on overloaded enum case

Issue Description:

Consider this code:

enum X {
  case x(a: Int)
  case x(b: Int)
}

This definition is happily accepted by swiftc, but the following:

switch X.x(a: 1) {
case .x(a: _):
  break
case .x(b: _):
  break
}

fails with the following error message:

error.swift:7:9: error: tuple pattern element label 'a' must be 'b'
case .x(a: _):

I'm not sure if the bug is due to the fact that the compiler allows the definition of cases with overlapping names (which IMO should be legal, because it's no different than overloading functions on argument names), or if it's due to an error in the switch handling within the compiler.

@belkadan
Copy link
Contributor

Related to what AndrewLitteken (JIRA User) is working on in SR-11159; may be fixed with those changes or may need more work.

@belkadan
Copy link
Contributor

cc also CodaFi (JIRA User)

@tkrajacic
Copy link

Same as SR-10077

@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

3 participants