Skip to content

Commit

Permalink
fix: give meaningful error on invalid annassign target
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Sep 30, 2020
1 parent 0b5669d commit 2479ef2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion vyper/context/validation/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ def __init__(
)

def visit_AnnAssign(self, node):
name = node.get("target.id")
if name is None:
raise VariableDeclarationException("Invalid assignment", node)

if not node.value:
raise VariableDeclarationException(
"Memory variables must be declared with an initial value", node
Expand All @@ -179,7 +183,7 @@ def visit_AnnAssign(self, node):
validate_expected_type(node.value, type_definition)

try:
self.namespace[node.target.id] = type_definition
self.namespace[name] = type_definition
except VyperException as exc:
raise exc.with_annotation(node) from None

Expand Down

0 comments on commit 2479ef2

Please sign in to comment.