Diagnostic and cause
СсылкаAssignment to imported binding
- Семейство
- topaz
- Этап
- resolve
- Код
TPZ3015
Причина и условия
Assigning to a selected import binding produces TPZ3015.
Связанное правило · Trigger and repair →Действия
Copy the value into your own let mut binding, or call an operation exported by the producing module.
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.
Response
СсылкаCopy the value into your own let mut binding, or call an operation exported by the producing module.
Reproduction and verification
СсылкаRejected program
Ссылкаimport lib { value }value = 2
Нет стандартного вывода.export let value = 1
Ожидаемый результат
Ожидаемый результат
Этап отклонения resolve. Ненулевой код завершения.
diagnostic-tpz3015 at
example.tpz:2:1
The expected diagnostic, cause, source location, and accompanying diagnostics are specified below. The verification status records whether this program has been run.
Corrected program
Ссылкаimport lib { value }let mut localValue = valuelocalValue = 2
export let value = 1
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.
This program applies the repair described above. The verification status records whether it has been run.