mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-24 10:41:57 +03:00
42 lines
733 B
Markdown
42 lines
733 B
Markdown
# Deprecated `mut` parameter
|
|
|
|
## Example
|
|
|
|
This error occurs when a function parameter is marked as `mut`.
|
|
|
|
Erroneous code example:
|
|
|
|
```js
|
|
circuit Foo {
|
|
bar: u8,
|
|
|
|
function bar(mut self) {
|
|
self.bar = 0;
|
|
}
|
|
}
|
|
```
|
|
|
|
The compiler will reject this code with, for example...:
|
|
|
|
```js
|
|
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`:
|
|
|
|
```js
|
|
circuit Foo {
|
|
bar: u8,
|
|
|
|
function bar(self) {
|
|
self.bar = 0;
|
|
}
|
|
}
|
|
```
|