mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-23 10:12:21 +03:00
733 B
733 B
Deprecated mut
parameter
Example
This error occurs when a function parameter is marked as mut
.
Erroneous code example:
circuit Foo {
bar: u8,
function bar(mut self) {
self.bar = 0;
}
}
The compiler will reject this code with, for example...:
Error [EPAR0370019]: `mut self` is no longer accepted. Use `&self` if you would like to pass in a mutable reference to `self`
--> test.leo:4:18
|
4 | function bar(mut self) {
| ^^^^^^^^
Solution
As the mut
modifier is implicitly assumed, the solution is to remove the mut
modifier from self
:
circuit Foo {
bar: u8,
function bar(self) {
self.bar = 0;
}
}