Merge pull request #853 from AleoHQ/bug/nested-access-fix

Reversed-Accesses
This commit is contained in:
Collin Chin 2021-04-13 17:30:38 -07:00 committed by GitHub
commit 817b7e0157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1039 additions and 147 deletions

View File

@ -472,7 +472,7 @@ impl ReconstructingReducer for Canonicalizer {
Expression::Value(value_expr) if assign.operation != AssignOperation::Assign => {
let mut left = Box::new(Expression::Identifier(assignee.identifier.clone()));
for access in assignee.accesses.iter().rev() {
for access in assignee.accesses.iter() {
match self.canonicalize_assignee_access(&access) {
AssigneeAccess::ArrayIndex(index) => {
left = Box::new(Expression::ArrayAccess(ArrayAccessExpression {

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,11 @@
circuit Foo {
f: u8,
y: (u8, u8),
function z (mut self) -> u16 {
self.y.0 += 1u8;
return 1u16
}
}
function main() {
let x = 10u32;
@ -14,7 +20,15 @@ function main() {
z.1 += 3u8;
console.assert(z.1 == 5u8);
let foo = Foo { f: 6u8 };
let foo = Foo { f: 6u8, y: (1u8, 1u8) };
foo.f += 2u8;
console.assert(foo.f == 8u8);
let a = [[0u8; 1]; 4];
a[2][0] += 1u8;
console.assert(a[2][0] == 1u8);
let b = [0u8; (4, 1)];
b[2][0] += 1u8;
console.assert(a[2][0] == 1u8);
}