Diagnostic and cause
LinkStray brace in string
- Family
- topaz
- Phase
- lex
- Code
TPZ0005
Cause and conditions
A literal closing brace in single-line string text must be escaped as \}. An unescaped brace produces TPZ0005.
Related rule: Trigger and repairResponse
Escape a literal closing brace. When interpolation was intended, supply the opening brace and expression.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 179-187 - compiler/crates/topaz_self_frontend/topaz/raw.tpz at
151141d7bb44· 414-414 - compiler/crates/topaz_self_frontend/topaz/raw.tpz at
151141d7bb44· 411-420 - TPZ0005 at
151141d7bb44
Compiler phase: lex.
Compiler explanation: A template/text string contains a brace that is not a valid interpolation boundary.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
- unescaped
}in a string literal; write\}Source
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ0005]: unescaped
}in a string literal; write\}
A closing brace appears unescaped in single-line string text. It is not closing a currently parsed interpolation.
Trigger and repair
A literal closing brace in single-line string text must be escaped as \}. An unescaped brace produces TPZ0005.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/raw.tpz at
151141d7bb44· 411-420 - TPZ0005 at
151141d7bb44
Response
LinkEscape a literal closing brace. When interpolation was intended, supply the opening brace and expression.
Reproduction and verification
LinkRejected program
Linklet message = "}"
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· 179-187 - compiler/crates/topaz_self_frontend/topaz/raw.tpz at
151141d7bb44· 414-414 - compiler/crates/topaz_self_frontend/topaz/raw.tpz at
151141d7bb44· 411-420 - TPZ0005 at
151141d7bb44
Corrected program
Linklet message = "\}"
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/raw.tpz at
151141d7bb44· 411-420 - TPZ0005 at
151141d7bb44