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-9340] Handling problem of same cases with different parameters. (Switch/Case) #51810

Open
swift-ci opened this issue Nov 25, 2018 · 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-9340
Radar None
Original Reporter batuhan (JIRA User)
Type Bug

Attachment: Download

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

md5: 04dfd2e82da06798a8a22a2af1f4e4ed

is duplicated by:

  • SR-9664 Enum with same case name behavior incorrect

relates to:

Issue Description:

Hello all,

As you know, Swift's switch / case statement allows us to pass parameters via cases. But I faced with this issue today. It doesn't allow you to use same cases with different parameters, but that allows to use create enum without any compile issues while compiling.

If you try to handle cases with switch statement that shows you possible choices according to enum.

But, If you define both of them, Xcode will appear a warning. "Case is already handled by previous patterns; consider removing it"

In addition to; If you define the cases without any parameter label. It won't allow to create same case with different types.

Note: I added all of required screenshots to attachments.

I believe, that's a strange bug, hope to fix soon.

swiftc --version output:

Apple Swift version 4.2.1 (swiftlang-1000.0.42 clang-1000.10.45.1)
Target: x86_64-apple-darwin18.0.0

Regards.

@belkadan
Copy link
Contributor

This is part of the efforts covered by SR-4691. CodaFi (JIRA User), @xedin, do you think it's worth keeping this open for that sub-task, or should we just collapse them together?

@xedin
Copy link
Member

xedin commented Nov 26, 2018

I think it's reasonable to collapse them together, WDYT CodaFi (JIRA User)?

@CodaFi
Copy link
Member

CodaFi commented Nov 27, 2018

Before we do that, I actually don't understand why you can overload by base name at all yet. I didn't implement this part of 155, and the decl checker is supposed to be rejecting these things.

@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

4 participants