Diagnostic and cause
LinkInvalid assignment target
- Family
- topaz
- Phase
- parse
- Code
TPZ2003
Cause and conditions
An assignment target must be an identifier, member access, or index access.
Related rule: Trigger and repairResponse
Assign to a mutable binding or to a supported member or index rooted in one. Mutability and type compatibility are checked after this syntax requirement.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 238-246 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 883-883 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 857-889 - compiler/crates/topaz_self_frontend/topaz/parser/expressions.tpz at
151141d7bb44· 1080-1092 - TPZ2003 at
151141d7bb44
Compiler phase: parse.
Compiler explanation: The left side of an assignment is not an assignable place.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
- assignment target must be an identifier, member access, or index access Source
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ2003]: assignment target must be an identifier, member access, or index access
The left side of an assignment is a computed expression. The parser accepts an identifier, member access, or index access in that position.
Trigger and repair
An assignment target must be an identifier, member access, or index access.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 857-889 - compiler/crates/topaz_self_frontend/topaz/parser/expressions.tpz at
151141d7bb44· 1080-1092 - TPZ2003 at
151141d7bb44
Response
LinkAssign to a mutable binding or to a supported member or index rooted in one. Mutability and type compatibility are checked after this syntax requirement.
Reproduction and verification
LinkRejected program
Link(1 + 2) = 3
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· 238-246 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 883-883 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 857-889 - compiler/crates/topaz_self_frontend/topaz/parser/expressions.tpz at
151141d7bb44· 1080-1092 - TPZ2003 at
151141d7bb44
Corrected program
Linklet mut value = 1value = 3
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· 857-889 - compiler/crates/topaz_self_frontend/topaz/parser/expressions.tpz at
151141d7bb44· 1080-1092 - TPZ2003 at
151141d7bb44