Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: guard against decorators in interface #3266

Merged
merged 3 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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