dart-lang / dart-lang/language
Using "continue" without label in a switch should continue with the next case
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
Using `continue` without a label in a `switch` case, should continue with the next case, similarly to how it does in loops. As of now, a `continue` must have a label, even if the case to continue with is right below.
Other languages allow to omit the `break` alltogether. Since that is prone to error in case it's simply forgotten, I'm fine with enforcing a keyword at the end of a case. However, a common usecase with `continue` in a `switch` is "continue with next case" which makes a label kind of redundant.
```dart
String foo = 'bar';
switch (foo) {
case 'first case':
print('doing first case');
break;
case 'bar':
print('doing bar case');
continue; // Error: A continue statement in a switch statement must have a label as a target
// Expectation: continue with next case, "default" here
default:
print('doing default case');
}
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the proposed switch example and the language specification scope described by this repository. Determine how an unlabeled continue should target the next case and how that interacts with the existing requirement for labeled continues. Done means the behavior and specification changes are agreed and fully defined; no implementation files or tests are named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100