Skip to content

Commit

Permalink
fix: guard against decorators in interfaces (#3266)
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg authored Feb 10, 2023
1 parent 50ee078 commit bf45181
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/parser/syntax/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
ArgumentException,
InvalidReference,
InvalidType,
StructureException,
SyntaxException,
TypeMismatch,
UnknownAttribute,
Expand Down Expand Up @@ -76,6 +77,14 @@ def test(a: address):
""",
SyntaxException,
),
(
"""
interface A:
@external
def foo(): nonpayable
""",
StructureException,
),
]


Expand Down
4 changes: 4 additions & 0 deletions vyper/semantics/types/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ def _get_class_functions(base_node: vy_ast.InterfaceDef) -> Dict[str, ContractFu
raise NamespaceCollision(
f"Interface contains multiple functions named '{node.name}'", node
)
if len(node.decorator_list) > 0:
raise StructureException(
"Function definition in interface cannot be decorated", node.decorator_list[0]
)
functions[node.name] = ContractFunctionT.from_FunctionDef(node, is_interface=True)

return functions
Expand Down

0 comments on commit bf45181

Please sign in to comment.