Skip to content

Commit

Permalink
fix: incorrect result when indexing a slice access
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwalker committed Jun 23, 2023
1 parent e5b2add commit f08b2f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion air-script/tests/list_comprehension/list_comprehension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl Air for ListComprehensionAir {
let aux_next = aux_frame.next();
result[0] = aux_current[0] - E::from(main_current[0]) * E::from(8_u64) * aux_current[7];
result[1] = aux_current[0] - E::from(main_current[0]) * (aux_next[4] - aux_next[8]);
result[2] = aux_current[2] - E::from(main_current[0]) * (aux_current[5] - aux_current[9]);
result[2] = aux_current[2] - E::from(main_current[0]) * (aux_current[5] - aux_current[10]);
result[3] = aux_current[0] - (E::ZERO + aux_current[1] - aux_current[4] - aux_current[8] + E::ONE + aux_current[2] - aux_current[5] - aux_current[9] + E::from(2_u64) + aux_current[3] - aux_current[6] - aux_current[10]);
}
}
4 changes: 2 additions & 2 deletions parser/src/ast/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,13 +767,13 @@ impl SymbolAccess {
Type::Felt => unreachable!(),
Type::Vector(len) if idx >= len => Err(InvalidAccessError::IndexOutOfBounds),
Type::Vector(_) => Ok(Self {
access_type: AccessType::Index(idx),
access_type: AccessType::Index(base_range.start + idx),
ty: Some(Type::Felt),
..self.clone()
}),
Type::Matrix(rows, _) if idx >= rows => Err(InvalidAccessError::IndexOutOfBounds),
Type::Matrix(_, cols) => Ok(Self {
access_type: AccessType::Index(idx),
access_type: AccessType::Index(base_range.start + idx),
ty: Some(Type::Vector(cols)),
..self.clone()
}),
Expand Down

0 comments on commit f08b2f8

Please sign in to comment.