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
표준 출력 없음.기대 결과
Repaired program
링크let mut value = 1value = 2
기대 결과
기대 결과
검사가 프로그램을 받아들입니다. 종료 코드 0.