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-13601] Boolean-valued case checking expressions #56036

Closed
typesanitizer opened this issue Sep 24, 2020 · 2 comments
Closed

[SR-13601] Boolean-valued case checking expressions #56036

typesanitizer opened this issue Sep 24, 2020 · 2 comments
Labels
compiler The Swift compiler in itself duplicate Resolution: Duplicates another issue expressions Feature: expressions feature A feature request or implementation pattern matching Feature: pattern matching swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal

Comments

@typesanitizer
Copy link

Previous ID SR-13601
Radar rdar://61035328
Original Reporter @typesanitizer
Type New Feature
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels New Feature, StarterProposal
Assignee None
Priority Medium

md5: 69379195ba792a711faff79b86aa3415

is duplicated by:

  • SR-4644 Create an expression for checking enum cases

Issue Description:

Allowing code patterns like (strawman syntax, we could potentially use ~= instead of =):

XCTAssertTrue(case .x(10) = expr1)
XCTAssertTrue(case .x(_) = expr2)

would make pattern checks more ergonomic.

The alternatives today are:

  • Use ==: Doesn't work if the type is not Equatable, doesn't work for ignoring bindings as in the second example.

  • Use an immediately invoked function expression (IIFE) with a switch statement: much more verbose than the suggested syntax.

See also: https://forums.swift.org/t/proposal-sanity-check-assigning-a-case-statement-to-a-boolean/40584

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal parser Area → compiler: The legacy C++ parser feature A feature request or implementation type checker Area → compiler: Semantic analysis SILGen Area → compiler: The SIL generation stage good first issue Good for newcomers duplicate Resolution: Duplicates another issue improvement and removed new feature StarterProposal labels Nov 11, 2022
@typesanitizer
Copy link
Author

@AnthonyLatsis could you mention which issue this is a duplicate of?

@AnthonyLatsis
Copy link
Collaborator

Duplicate of #47221

@AnthonyLatsis AnthonyLatsis marked this as a duplicate of #47221 Nov 12, 2022
@AnthonyLatsis AnthonyLatsis added pattern matching Feature: pattern matching expressions Feature: expressions and removed good first issue Good for newcomers improvement parser Area → compiler: The legacy C++ parser type checker Area → compiler: Semantic analysis SILGen Area → compiler: The SIL generation stage labels Feb 25, 2023
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 expressions Feature: expressions feature A feature request or implementation pattern matching Feature: pattern matching swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal
Projects
None yet
Development

No branches or pull requests

2 participants