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-3711] Make .member lookups in Optional<T> context ambiguous if member can be found in both Optional and T #46296

Closed
jckarter opened this issue Jan 24, 2017 · 3 comments
Labels
compiler The Swift compiler in itself duplicate Resolution: Duplicates another issue good first issue Good for newcomers improvement

Comments

@jckarter
Copy link
Member

Previous ID SR-3711
Radar None
Original Reporter @jckarter
Type Improvement
Status Closed
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, StarterProposal
Assignee None
Priority Medium

md5: 350c81741cea712fd43b212192d41c93

duplicates:

  • SR-2176 Add warning for ambiguous enum value assignment

relates to:

  • SR-2176 Add warning for ambiguous enum value assignment

Issue Description:

https://twitter.com/pilky/status/823942988665589760

If you have a static Self-typed member some or none in your own type, attempting to use the contextual lookup in Optional context will favor Optional's members:

enum PiggyState {
  case market, home, roastBeef, none
}

func setState(to state: PiggyState?) {}

setState(to: .none) // passes `Optional.none`, not `.some(.none)`

Instead of quietly treating this as Optional.none, we should raise an error (or warning for source compatibility) that the lookup is ambiguous.

@dduan
Copy link
Collaborator

dduan commented Jan 28, 2017

If we issue a warning, this wouldn't require a proposal, right?

@belkadan
Copy link
Contributor

belkadan commented Oct 3, 2017

I'm inclined to agree with Daniel. A warning is fine (SR-2176), and then we don't need a proposal.

@jckarter
Copy link
Member Author

jckarter commented Oct 3, 2017

Sure, a warning is fine. I'll dupe this.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added good first issue Good for newcomers duplicate Resolution: Duplicates another issue and removed StarterProposal labels Nov 11, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself duplicate Resolution: Duplicates another issue good first issue Good for newcomers improvement
Projects
None yet
Development

No branches or pull requests

4 participants