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-8283] Enum cases named "none" can cause ambiguity with Optional's "none" #50814

Closed
BigZaphod opened this issue Jul 17, 2018 · 1 comment
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@BigZaphod
Copy link

Previous ID SR-8283
Radar None
Original Reporter @BigZaphod
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee @BigZaphod
Priority Medium

md5: 6519b15f5a5403dca6d855c198d0f330

duplicates:

  • SR-2176 Add warning for ambiguous enum value assignment

Issue Description:

In the following code snippet, foo is actually nil because the compiler decides to pick Optional.none instead of MyTest.none. I spent a long time tracking this down!

enum MyTest: UInt8 {
   case none, one, two, three
}
let foo: MyTest? = .none

Another case where this occurs is in code like this:

if foo == .none { \* stuff *\ }

There are no warnings when this happens. I think there should probably at least be a fixit warning that says something about there being an ambiguity here and offering the user fix it with either `Optional.none` or `MyTest.none`.

@keith
Copy link
Collaborator

keith commented Jul 17, 2018

There have been a bunch of submissions about this one, I think this is the source of truth now https://bugs.swift.org/browse/SR-2176

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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.
Projects
None yet
Development

No branches or pull requests

2 participants