Diagnostic and cause
СсылкаImmutable binding mutation
- Семейство
- topaz
- Этап
- check
- Код
TPZ5003
Причина и условия
An assignment through an immutable root binding is rejected with TPZ5003 at that root. Declare the root with let mut when subsequent assignment is required.
Связанное правило · Assignment requires a mutable root binding →Действия
Declare a local root with let mut when it must change. Otherwise, compute a new value and bind it separately.
Compiler phase: check/runtime.
Compiler explanation: The program tried to assign through a binding that was not declared mutable.
Message templates are Pending. The explanation above is not an observed CLI message.
Observed for the candidate in Topaz 5.21.3. Execution
- error[TPZ5003]:
valueis immutable; declare it withlet mut
An assignment through an immutable root binding is rejected with TPZ5003 at that root. Declare the root with let mut when subsequent assignment is required.
Assignment requires a mutable root binding
An assignment through an immutable root binding is rejected with TPZ5003 at that root. Declare the root with let mut when subsequent assignment is required.
Response
СсылкаDeclare a local root with let mut when it must change. Otherwise, compute a new value and bind it separately.
Reproduction and verification
СсылкаRejected program
Ссылкаlet value = 1value = 2
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
diagnostic-tpz5003 at
example.tpz:2:1
Repaired program
Ссылкаlet mut value = 1value = 2
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.