Diagnostic and cause
LinkUnknown loop label
- Family
- topaz
- Phase
- check
- Code
TPZ5720
Cause and conditions
A labeled break must name an enclosing loop that is active at the statement. Breaking to an absent label is rejected with TPZ5720 at the break statement.
Related rule: Labeled break needs an enclosing loopResponse
Declare the intended label immediately after loop, or use the label of an enclosing loop. The repaired program declares the label used by its break.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 961-970 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
151141d7bb44· 363-363 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
17711dcdbc9b· 342-369
Compiler phase: check.
Compiler explanation: A labeled break or continue names a loop label that is not in scope.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
- no loop labeled
'⟨value⟩in scope Source
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ5720]: no loop labeled
'missingin scope
A labeled break must name an enclosing loop that is active at the statement. Breaking to an absent label is rejected with TPZ5720 at the break statement.
Labeled break needs an enclosing loop
A labeled break must name an enclosing loop that is active at the statement. Breaking to an absent label is rejected with TPZ5720 at the break statement.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
17711dcdbc9b· 342-369
Response
LinkDeclare the intended label immediately after loop, or use the label of an enclosing loop. The repaired program declares the label used by its break.
Reproduction and verification
LinkRejected program
Linkloop {break 'missing}
No stdout.
Expected result
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
17711dcdbc9b· 342-369
Repaired program
Linkloop 'missing {break 'missing}
Expected result
Expected result
Checking accepts the program. Exit code 0.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
17711dcdbc9b· 342-369