From f39effaccc52d516243b84b683b31220192d4970 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Fri, 17 Nov 2023 23:06:47 +0800 Subject: [PATCH] fix constant var decl expr visit --- vyper/semantics/analysis/module.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vyper/semantics/analysis/module.py b/vyper/semantics/analysis/module.py index 651c92c4aa..02965eecd7 100644 --- a/vyper/semantics/analysis/module.py +++ b/vyper/semantics/analysis/module.py @@ -240,9 +240,11 @@ def _validate_self_namespace(): raise exc.with_annotation(node) from None if node.is_constant: - ExprVisitor().visit(node.value, type_) if not node.value: raise VariableDeclarationException("Constant must be declared with a value", node) + + ExprVisitor().visit(node.value, type_) + if not check_variable_constancy(node.value, VariableConstancy.COMPILE_TIME_CONSTANT): raise StateAccessViolation("Value must be a literal", node.value)