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-9664] Enum with same case name behavior incorrect #52108

Open
bestwnh opened this issue Jan 15, 2019 · 4 comments
Open

[SR-9664] Enum with same case name behavior incorrect #52108

bestwnh opened this issue Jan 15, 2019 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@bestwnh
Copy link

bestwnh commented Jan 15, 2019

Previous ID SR-9664
Radar None
Original Reporter @bestwnh
Type Bug

Attachment: Download

Environment

Xcode 10.1

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

md5: f9e3495981f937065413b753ad32c6a9

duplicates:

  • SR-9340 Handling problem of same cases with different parameters. (Switch/Case)

Issue Description:

If define same case name for enum, the later one will work fine but previous one would be limited and can't be `switch` correctly.

for example:

enum Line {
    case dash(width: Float)
    case dash(width: Float, dashWidth: Float, spaceWidth: Float)
}

if case Line.dash = Line.dash(width: 1) {
    print("equal")
} else {
    print("not equal")
}

It will print "not equal".

sample code is attached.

More describe you can find in this this article TinySolution: Resolve the restrictions of enum under the "Strange phenomenon" chapter.

@bestwnh
Copy link
Author

bestwnh commented Jan 15, 2019

@nkcsgexi FYI.

@belkadan
Copy link
Contributor

SE-0155 hasn't actually been implemented yet; it's still in progress. CodaFi (JIRA User), do you have something to dup this to?

@CodaFi
Copy link
Member

CodaFi commented Jan 15, 2019

This was deleted in 025555f, but none of the tests that were changed involve enums with associated values. Should be a simple change to redeclaration checking to get the error back, but we've already gone through a release where this "works"...

@bestwnh
Copy link
Author

bestwnh commented Jan 16, 2019

I think it should be actually work with a fix or source breaking change to make it an error. All Of these choices better than it looks like "works" but actually not.

@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