leo/tests/compiler/mutability/circuit_function_const.leo

23 lines
341 B
Plaintext
Raw Normal View History

2021-05-03 17:28:53 +03:00
/*
namespace: Compile
expectation: Fail
2021-05-05 18:29:44 +03:00
input_file: input/dummy.in
2021-05-03 17:28:53 +03:00
*/
circuit Foo {
x: u32
function foo(mut self) {
self.x = 10;
}
}
// cannot call mutable member function 'foo' of circuit 'Foo' from immutable context
2021-05-05 18:29:44 +03:00
function main() -> bool {
2021-05-03 17:28:53 +03:00
const a = Foo { x: 1 };
a.foo();
2021-05-05 18:29:44 +03:00
return a.x == 10u32;
}