Skip to content

Commit bf45181

Browse files
authored
fix: guard against decorators in interfaces (#3266)
1 parent 50ee078 commit bf45181

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tests/parser/syntax/test_interfaces.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
ArgumentException,
66
InvalidReference,
77
InvalidType,
8+
StructureException,
89
SyntaxException,
910
TypeMismatch,
1011
UnknownAttribute,
@@ -76,6 +77,14 @@ def test(a: address):
7677
""",
7778
SyntaxException,
7879
),
80+
(
81+
"""
82+
interface A:
83+
@external
84+
def foo(): nonpayable
85+
""",
86+
StructureException,
87+
),
7988
]
8089

8190

vyper/semantics/types/user.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,10 @@ def _get_class_functions(base_node: vy_ast.InterfaceDef) -> Dict[str, ContractFu
468468
raise NamespaceCollision(
469469
f"Interface contains multiple functions named '{node.name}'", node
470470
)
471+
if len(node.decorator_list) > 0:
472+
raise StructureException(
473+
"Function definition in interface cannot be decorated", node.decorator_list[0]
474+
)
471475
functions[node.name] = ContractFunctionT.from_FunctionDef(node, is_interface=True)
472476

473477
return functions

0 commit comments

Comments
 (0)