Diagnostic and cause
LinkAssignment to imported binding
- Family
- topaz
- Phase
- resolve
- Code
TPZ3015
Cause and conditions
Assigning to a selected import binding produces TPZ3015.
Related rule: Trigger and repairResponse
Copy the value into your own let mut binding, or call an operation exported by the producing module.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 472-480 - compiler/crates/topaz_self_frontend/topaz/resolver/scopes_walk.tpz at
151141d7bb44· 716-716 - compiler/crates/topaz_self_frontend/topaz/resolver/scopes_walk.tpz at
151141d7bb44· 694-720 - TPZ3015 at
151141d7bb44
Compiler phase: resolve.
Compiler explanation: The program attempts to assign to a binding imported from another module.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
⟨value⟩is an imported binding and cannot be assigned Source⟨value⟩.is an exported binding viewed through a namespace and cannot be assigned Source⟨value⟩
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ3015]:
valueis an imported binding and cannot be assigned
The assignment targets a name introduced by a selected import. Importing a binding does not make it mutable in the importing module.
Trigger and repair
Assigning to a selected import binding produces TPZ3015.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/resolver/scopes_walk.tpz at
151141d7bb44· 694-720 - TPZ3015 at
151141d7bb44
Response
LinkCopy the value into your own let mut binding, or call an operation exported by the producing module.
Reproduction and verification
LinkRejected program
Linkimport lib { value }value = 2
No stdout.
export let value = 1
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· 472-480 - compiler/crates/topaz_self_frontend/topaz/resolver/scopes_walk.tpz at
151141d7bb44· 716-716 - compiler/crates/topaz_self_frontend/topaz/resolver/scopes_walk.tpz at
151141d7bb44· 694-720 - TPZ3015 at
151141d7bb44
Corrected program
Linkimport lib { value }let mut localValue = valuelocalValue = 2
export let value = 1
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/resolver/scopes_walk.tpz at
151141d7bb44· 694-720 - TPZ3015 at
151141d7bb44