Diagnostic and cause
LinkInvalid defer body
- Family
- topaz
- Phase
- parse
- Code
TPZ2004
Cause and conditions
The body of a defer statement must be a block (topaz.decision.defer-block-only.1).
Related rule: Trigger and repairResponse
Place the deferred work in a block.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 247-255 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 827-827 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 816-833 - TPZ2004 at
151141d7bb44
Compiler phase: parse.
Compiler explanation: A defer statement body is neither a block nor a call expression.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
defertakes a block or a call Source
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ2004]:
defertakes a block or a call
A defer statement has a body that is not a block.
Trigger and repair
The body of a defer statement must be a block (topaz.decision.defer-block-only.1).
Source evidence
- compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 816-833 - TPZ2004 at
151141d7bb44
Response
LinkPlace the deferred work in a block.
Reproduction and verification
LinkRejected program
Linkdefer 1
No stdout.
Expected result
The expected diagnostic, cause, source location, and accompanying diagnostics are specified below. The verification status records whether this program has been run.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 247-255 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 827-827 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 816-833 - TPZ2004 at
151141d7bb44
Corrected program
Linkdefer {}
Expected result
Expected result
Checking accepts the program. Exit code 0.
This program applies the repair described above. The verification status records whether it has been run.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 816-833 - TPZ2004 at
151141d7bb44