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-8113] Emit a diagnostic when fallthrough is not the last statement of a case block #50645

Closed
rudkx opened this issue Jun 26, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers type checker Area → compiler: Semantic analysis

Comments

@rudkx
Copy link
Member

rudkx commented Jun 26, 2018

Previous ID SR-8113
Radar None
Original Reporter @rudkx
Type Bug
Status Closed
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, StarterBug, TypeChecker
Assignee None
Priority Medium

md5: f56d70a6725a2ca637367b60a49ae340

Issue Description:

We treat fallthrough as if it is "goto $next-case", skipping any code that follows. We should really emit a diagnostic if it is not the last statement in a case block.

For example:

func foo(i: Int) {
  switch i {
  case 1:
    fallthrough
    switch i {
    case 1: break
    default: break
    }
  default:
  break
  }
}
@rudkx
Copy link
Member Author

rudkx commented Jun 26, 2018

Ah, we actually emit an unreachable code warning for this. I need to compile without -typecheck more often!

@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. compiler The Swift compiler in itself good first issue Good for newcomers type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

1 participant