From 9880fbfc68715ea003dfcbb29b4bf9d2c5ab8b73 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Thu, 28 Sep 2023 16:12:25 +0800 Subject: [PATCH] simplify visit_For --- vyper/semantics/analysis/local.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/vyper/semantics/analysis/local.py b/vyper/semantics/analysis/local.py index 2044154ed4..52d7b1fa61 100644 --- a/vyper/semantics/analysis/local.py +++ b/vyper/semantics/analysis/local.py @@ -360,7 +360,7 @@ def visit_For(self, node): if bound is None: n_val = derive_folded_value(n) if not isinstance(n_val, int): - raise StateAccessViolation("Value must be a literal", n) + raise StateAccessViolation("Value must be a literal integer", n) if n_val <= 0: raise StructureException("For loop must have at least 1 iteration", args[0]) type_list = get_possible_types_from_node(n) @@ -398,9 +398,7 @@ def visit_For(self, node): ) right_val = derive_folded_value(args[1].right) - if not isinstance(args[1].right, vy_ast.Int) and not ( - isinstance(args[1].right, vy_ast.Name) and right_val - ): + if right_val is None: raise InvalidLiteral("Literal must be an integer", args[1].right) if right_val < 1: raise StructureException(