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-4196] Allow #if (conditional compilation) to guard switch cases #46779

Closed
belkadan opened this issue Mar 8, 2017 · 3 comments
Closed

[SR-4196] Allow #if (conditional compilation) to guard switch cases #46779

belkadan opened this issue Mar 8, 2017 · 3 comments
Assignees
Labels
compiler The Swift compiler in itself duplicate Resolution: this issue duplicates an existing one feature A feature request or implementation good first issue Good for newcomers improvement parser

Comments

@belkadan
Copy link
Contributor

belkadan commented Mar 8, 2017

Previous ID SR-4196
Radar rdar://problem/16980851
Original Reporter @belkadan
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, LanguageFeatureRequest, StarterProposal
Assignee @rintaro
Priority Medium

md5: c3d4da1a290a1496adc214b1fce9223b

relates to:

  • SR-4079 Availability of enum case does not propagate to its switch case scope.
  • SR-2 Build configuration directives can not wrap switch cases

Issue Description:

Currently #if can only be used to guard complete declarations or complete statements, due to the (deliberate) modeling as part of the AST rather than as a textual preprocessing step. However, there's one more place where it would structurally make sense to allow #if: switch cases. This may be important if a new case is added in a new version of Swift. Right now you'd have to write the switch twice.

@belkadan
Copy link
Contributor Author

belkadan commented Mar 8, 2017

This probably does have to go through swift-evolution, but I don't expect much pushback. Rather, I expect discussion to try to spiral out to all the other ways we could change #if, and I recommend keeping the proposal focused regardless.

@rintaro
Copy link
Mannequin

rintaro mannequin commented Apr 3, 2018

Implemented in Swift 4.1

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added good first issue Good for newcomers and removed StarterProposal labels Nov 11, 2022
@AnthonyLatsis
Copy link
Collaborator

PR: #9457

@AnthonyLatsis AnthonyLatsis added duplicate Resolution: this issue duplicates an existing one parser 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: this issue duplicates an existing one feature A feature request or implementation good first issue Good for newcomers improvement parser
Projects
None yet
Development

No branches or pull requests

2 participants