Skip to content

Commit

Permalink
Bypass array bounds check when iterating over arrays.
Browse files Browse the repository at this point in the history
As we make a copy of the loop source, it is logically impossible to ever violate this bound.
  • Loading branch information
FeepingCreature committed Jan 1, 2024
1 parent ac651c5 commit a31672e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/neat/stuff.nt
Original file line number Diff line number Diff line change
Expand Up @@ -3521,14 +3521,14 @@ class ASTExtForLoop : ASTStatement
ASTStatement declIdentifier() {
if (!arrayType.mutableElements) {
return valueMatch.type.case(
(:auto_): compiler.$stmt auto $valueIdent = __borrow(__source[$keyIdent]); ,
(:none): compiler.$stmt auto $valueIdent = __borrow(__source[$keyIdent]); ,
ASTSymbol type: compiler.$stmt $type $valueIdent = __borrow(__source[$keyIdent]); );
(:auto_): compiler.$stmt auto $valueIdent = __borrow(__source.ptr[$keyIdent]); ,
(:none): compiler.$stmt auto $valueIdent = __borrow(__source.ptr[$keyIdent]); ,
ASTSymbol type: compiler.$stmt $type $valueIdent = __borrow(__source.ptr[$keyIdent]); );
}
return valueMatch.type.case(
(:auto_): compiler.$stmt auto $valueIdent = __source[$keyIdent]; ,
(:none): compiler.$stmt auto $valueIdent = __source[$keyIdent]; ,
ASTSymbol type: compiler.$stmt $type $valueIdent = __source[$keyIdent]; );
(:auto_): compiler.$stmt auto $valueIdent = __source.ptr[$keyIdent]; ,
(:none): compiler.$stmt auto $valueIdent = __source.ptr[$keyIdent]; ,
ASTSymbol type: compiler.$stmt $type $valueIdent = __source.ptr[$keyIdent]; );
}
ASTStatement loop = compiler.$stmt {
auto __source = $astSource;
Expand Down

0 comments on commit a31672e

Please sign in to comment.