Skip to content

Commit

Permalink
we have a postcondition!
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Feb 22, 2024
1 parent 0b57eda commit bafbfe9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions vyper/semantics/analysis/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,11 @@ def visit_For(self, node):
target_type = type_from_annotation(node.target.annotation, DataLocation.MEMORY)

iter_var = None
is_range = False
if isinstance(node.iter, vy_ast.Call):
self._analyse_range_iter(node.iter, target_type)
is_range = True

# sanity check the postcondition of analyse_range_iter
assert isinstance(target_type, IntegerT)
else:
iter_var = self._analyse_list_iter(node.iter, target_type)

Expand All @@ -525,10 +526,6 @@ def visit_For(self, node):
self.namespace[target_name] = VarInfo(
target_type, modifiability=Modifiability.RUNTIME_CONSTANT
)
# ideally should be performed before calling _analyse_range_iter
# but there is a dependence on the namespace update
if is_range:
validate_expected_type(node.target.target, IntegerT.any())

self.expr_visitor.visit(node.target.target, target_type)

Expand Down

0 comments on commit bafbfe9

Please sign in to comment.