Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Jul 25, 2023
1 parent d707c68 commit 60a5e41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/parser/features/iteration/test_for_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def repeat(n: uint256) -> uint256:
for n in range(7):
assert c.repeat(n) == sum(range(n))

# n greater than bound
# check codegen inserts assertion for n greater than bound
assert_tx_failed(lambda: c.repeat(7))


Expand Down
3 changes: 3 additions & 0 deletions vyper/codegen/stmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ def _parse_For_range(self):
loop_body.append(["mstore", iptr, i])
loop_body.append(parse_body(self.stmt.body, self.context))

# NOTE: codegen for `repeat` inserts an assertion that rounds <= rounds_bound.
# if we ever want to remove that, we need to manually add the assertion
# where it makes sense.
ir_node = IRnode.from_list(["repeat", i, start, rounds, rounds_bound, loop_body])
del self.context.forvars[varname]

Expand Down

0 comments on commit 60a5e41

Please sign in to comment.