Diagnostic and cause
LinkReserved binding name
- Family
- topaz
- Phase
- parse
- Code
TPZ2012
Cause and conditions
A record declaration cannot use set or map as its name.
Response
Give the record a different name, such as Item. Keep set and map for collection literals. Use None() to construct an empty Option.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 319-327 - compiler/crates/topaz_self_frontend/topaz/parser/core.tpz at
151141d7bb44· 179-179 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 362-362 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 354-367 - compiler/crates/topaz_self_frontend/topaz/parser/core.tpz at
151141d7bb44· 175-186 - TPZ2012 at
151141d7bb44
Compiler phase: parse.
Compiler explanation: A binding position uses a name reserved for a constructor or language form.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
Noneis the Option constructor (§22.1) and cannot be a binding name Source⟨value⟩is reserved for the⟨value⟩ { … }collection literal (§6) and cannot be a record name Source
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ2012]:
setis reserved for theset { … }collection literal (§6) and cannot be a record name
The record is named set. Record names set and map are reserved for collection literals. This code also covers reserved None binding positions.
Trigger and repair
A record declaration cannot use set or map as its name.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 354-367 - compiler/crates/topaz_self_frontend/topaz/parser/core.tpz at
151141d7bb44· 175-186 - TPZ2012 at
151141d7bb44
Response
LinkGive the record a different name, such as Item. Keep set and map for collection literals. Use None() to construct an empty Option.
Reproduction and verification
LinkRejected program
Linkrecord set {value: int}
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· 319-327 - compiler/crates/topaz_self_frontend/topaz/parser/core.tpz at
151141d7bb44· 179-179 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 362-362 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 354-367 - compiler/crates/topaz_self_frontend/topaz/parser/core.tpz at
151141d7bb44· 175-186 - TPZ2012 at
151141d7bb44
Corrected program
Linkrecord Item {value: int}
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· 354-367 - compiler/crates/topaz_self_frontend/topaz/parser/core.tpz at
151141d7bb44· 175-186 - TPZ2012 at
151141d7bb44