Skip to content

Commit 5bbc496

Browse files
revert bad validation
1 parent 73a3228 commit 5bbc496

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

vyper/ast/nodes.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,11 +1267,6 @@ def validate(self):
12671267
if not isinstance(self.target, Name):
12681268
raise VariableDeclarationException("Invalid variable declaration", self.target)
12691269

1270-
if self.value is None:
1271-
raise VariableDeclarationException(
1272-
"Local variables must be declared with an initial value", self
1273-
)
1274-
12751270

12761271
class VariableDecl(VyperNode):
12771272
"""

vyper/semantics/analysis/local.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
StructureException,
1818
TypeCheckFailure,
1919
TypeMismatch,
20+
VariableDeclarationException,
2021
VyperException,
2122
)
2223
from vyper.semantics.analysis.base import (
@@ -325,12 +326,12 @@ def visit(self, node):
325326
super().visit(node)
326327

327328
def visit_AnnAssign(self, node):
328-
name = node.target.id
329-
330-
# sanity check postconditions of AnnAssign.validate()
331-
assert isinstance(node.target, vy_ast.Name)
332-
assert node.value is not None
329+
if node.value is None:
330+
raise VariableDeclarationException(
331+
"Local variables must be declared with an initial value"
332+
)
333333

334+
name = node.target.id
334335
typ = type_from_annotation(node.annotation, DataLocation.MEMORY)
335336

336337
# validate the value before adding it to the namespace

0 commit comments

Comments
 (0)