dotnet / dotnet/roslyn

Test plan for "labeled break and continue"

Open
#83,209 1 comment 0 reactions 2 assignees Claimed by @jjonescz View on GitHub
Area-Compilers
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

Championed issue: https://github.com/dotnet/csharplang/issues/9875
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/labeled-break-continue.md
Feature branch: https://github.com/dotnet/roslyn/tree/features/labeled-break-and-continue

```antlr
break_statement
: attribute_list* 'break' identifier_name? ';'
;

continue_statement
: attribute_list* 'continue' identifier_name? ';'
;
```

```cs
[Experimental(global::Microsoft.CodeAnalysis.RoslynExperiments.PreviewLanguageFeatureApi, UrlFormat = @"https://github.com/dotnet/roslyn/issues/83266")]
public static BreakStatementSyntax BreakStatement(SyntaxList attributeLists, SyntaxToken breakKeyword, IdentifierNameSyntax? name, SyntaxToken semicolonToken)
...
```

# Compiler
- [x] LangVer (unconditional parsing, check during binding)
- [x] Binding:
- [x] happy cases in loops and switches
- [x] error cases (binding to missing label, to non-enclosing-loop label)
- [x] in lambdas, local functions
- [x] in iterators/async/async-iterators
- [x] in nested loop/switch constructs
- [x] leaving `finally`
- [x] data flow analysis (definite assignment, reporting unused labels, nullability analysis)
- [x] semantic model
- [x] GetSymbolInfo
- [x] LookupSymbol (unchanged, N/A)
- [x] IOperation
- [x] CFG
- [x] NormalizeWhitespace
- [ ] Public API review (tracked by https://github.com/dotnet/roslyn/issues/83266)
- [x] Runtime: check the IL we generate makes the JIT's loop recognition happy (same code as `goto`)
- [x] Compat breaks (N/A)

# Productivity
- [x] Completion
- [x] GoToDefinition, Hover, Rename, FindReferences
- [x] ReferenceHighlighting
- [x] BreakpointSpans
- [x] Loop/switch highlighting
- [x] ExtractMethod
- [x] Formatting

# Spec
- [x] What do we expect with stacked labels? `label1: label2: foreach (...) { break label1 }`
- [x] How are labels looked up? `foreach (...) { break label; /* do we know which label you're referring to here? */ } label:;`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.