Diagnostic and cause
LinkMutable export is rejected
- Family
- topaz
- Phase
- resolve
- Code
TPZ3011
Cause and conditions
An exported mutable let binding produces TPZ3011.
Related rule: Trigger and repairResponse
Export an immutable binding. Use a separate operation when callers need to request a change.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 436-444 - compiler/crates/topaz_self_frontend/topaz/resolver/modules_tables.tpz at
151141d7bb44· 333-333 - compiler/crates/topaz_self_frontend/topaz/resolver/modules_tables.tpz at
151141d7bb44· 325-338 - TPZ3011 at
151141d7bb44
Compiler phase: resolve.
Compiler explanation: A module tries to export a mutable let binding.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
export let mutis a static error: exported bindings are immutable views Source
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ3011]:
export let mutis a static error: exported bindings are immutable views
The declaration combines export with let mut. Exported bindings provide immutable views.
Trigger and repair
An exported mutable let binding produces TPZ3011.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/resolver/modules_tables.tpz at
151141d7bb44· 325-338 - TPZ3011 at
151141d7bb44
Response
LinkExport an immutable binding. Use a separate operation when callers need to request a change.
Reproduction and verification
LinkRejected program
Linkexport let mut value = 1
No stdout.
Expected result
Expected result
Rejection during resolve. Nonzero exit.
TPZ3011diagnostic-tpz3011 atexample.tpz:1:16
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· 436-444 - compiler/crates/topaz_self_frontend/topaz/resolver/modules_tables.tpz at
151141d7bb44· 333-333 - compiler/crates/topaz_self_frontend/topaz/resolver/modules_tables.tpz at
151141d7bb44· 325-338 - TPZ3011 at
151141d7bb44
Corrected program
Linkexport 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/modules_tables.tpz at
151141d7bb44· 325-338 - TPZ3011 at
151141d7bb44