Skip to content

Commit

Permalink
fix implements visit
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Feb 28, 2023
1 parent 7efc115 commit b7d7d88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 15 additions & 0 deletions tests/parser/syntax/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ def foo(): nonpayable
""",
StructureException,
),
(
"""
implements: 123
""",
StructureException,
),
(
"""
struct Foo:
a: uint256
implements: Foo
""",
StructureException,
),
]


Expand Down
7 changes: 4 additions & 3 deletions vyper/semantics/analysis/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ def __init__(
self_members[fn_name].recursive_calls = function_set

def visit_ImplementsDecl(self, node):
interface_name = node.annotation.id
type_ = type_from_annotation(node.annotation)
if not isinstance(type_, InterfaceT):
raise StructureException("Invalid interface name", node.annotation)

other_iface = self.namespace[interface_name]
other_iface.validate_implements(node)
type_.validate_implements(node)

def visit_VariableDecl(self, node):
name = node.get("target.id")
Expand Down

0 comments on commit b7d7d88

Please sign in to comment.