diff --git a/vyper/codegen/stmt.py b/vyper/codegen/stmt.py index 9dc75b46ba..3ecb0afdc3 100644 --- a/vyper/codegen/stmt.py +++ b/vyper/codegen/stmt.py @@ -316,10 +316,8 @@ def _parse_For_list(self): with self.context.range_scope(): iter_list = Expr(self.stmt.iter, self.context).ir_node - # override with type inferred at typechecking time - # TODO investigate why stmt.target.type != stmt.iter.type.value_type target_type = self.stmt.target._metadata["type"] - iter_list.typ.value_type = target_type + assert target_type == iter_list.typ.value_type # user-supplied name for loop variable varname = self.stmt.target.id diff --git a/vyper/semantics/analysis/annotation.py b/vyper/semantics/analysis/annotation.py index d309f102cd..01ca51d7f4 100644 --- a/vyper/semantics/analysis/annotation.py +++ b/vyper/semantics/analysis/annotation.py @@ -85,14 +85,14 @@ def visit_Return(self, node): def visit_For(self, node): if isinstance(node.iter, (vy_ast.Name, vy_ast.Attribute)): self.expr_visitor.visit(node.iter) - # typecheck list literal as static array + + iter_type = node.target._metadata["type"] if isinstance(node.iter, vy_ast.List): - value_type = get_common_types(*node.iter.elements).pop() + # typecheck list literal as static array len_ = len(node.iter.elements) - self.expr_visitor.visit(node.iter, SArrayT(value_type, len_)) + self.expr_visitor.visit(node.iter, SArrayT(iter_type, len_)) if isinstance(node.iter, vy_ast.Call) and node.iter.func.id == "range": - iter_type = node.target._metadata["type"] for a in node.iter.args: self.expr_visitor.visit(a, iter_type) for a in node.iter.keywords: