Merge pull request #869 from AleoHQ/bug/calling-mut-method-from-immutable-context

bug-fix-852
This commit is contained in:
Collin Chin 2021-04-15 11:51:11 -07:00 committed by GitHub
commit 5f46ccc026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -71,7 +71,7 @@ impl<'a> ExpressionNode<'a> for CallExpression<'a> {
} }
fn is_mut_ref(&self) -> bool { fn is_mut_ref(&self) -> bool {
false true
} }
fn const_value(&self) -> Option<ConstValue> { fn const_value(&self) -> Option<ConstValue> {

View File

@ -5,8 +5,21 @@ circuit TestMe {
self.x += 1; self.x += 1;
return self.x; return self.x;
} }
function new() -> Self {
return Self { x: 1u8 };
}
}
function my_fn() -> TestMe {
return TestMe { x: 0u8 };
} }
function main () { function main () {
const t = TestMe {x: 6u8}.test_me(); const t = TestMe {x: 6u8}.test_me();
console.assert(t == 7u8);
const u = my_fn().test_me();
console.assert(u == 1u8);
const v = TestMe::new().test_me();
console.assert(v == 2u8);
} }