diff --git a/tests/functional/syntax/test_interfaces.py b/tests/functional/syntax/test_interfaces.py index baf0c73c30..007ee61c93 100644 --- a/tests/functional/syntax/test_interfaces.py +++ b/tests/functional/syntax/test_interfaces.py @@ -600,7 +600,6 @@ def bar(): compiler.compile_code(main, input_bundle=input_bundle) -@pytest.mark.xfail def test_intrinsic_interfaces_default_function(make_input_bundle, get_contract): lib1 = """ @external @@ -618,6 +617,26 @@ def bar(): """ input_bundle = make_input_bundle({"lib1.vy": lib1}) - # TODO make the exception more precise once fixed - with pytest.raises(Exception): # noqa: B017 + with pytest.raises(ValueError): + compiler.compile_code(main, input_bundle=input_bundle) + + +def test_intrinsic_interfaces_default_function_staticcall(make_input_bundle, get_contract): + lib1 = """ +@external +@view +def __default__() -> int128: + return 43 + """ + main = """ +import lib1 + +@external +def bar(): + foo:int128 = 0 + foo = staticcall lib1.__at__(self).__default__() + """ + input_bundle = make_input_bundle({"lib1.vy": lib1}) + + with pytest.raises(ValueError): compiler.compile_code(main, input_bundle=input_bundle) diff --git a/vyper/ast/nodes.py b/vyper/ast/nodes.py index ccc80947e4..f835e8fd53 100644 --- a/vyper/ast/nodes.py +++ b/vyper/ast/nodes.py @@ -1304,6 +1304,8 @@ def validate(self): self.value, hint="did you forget parentheses?", ) + if hasattr(self.value.func, "attr") and self.value.func.attr == "__default__": + raise ValueError("function __default__ cannot be called") class StaticCall(ExprNode): @@ -1316,6 +1318,8 @@ def validate(self): self.value, hint="did you forget parentheses?", ) + if hasattr(self.value.func, "attr") and self.value.func.attr == "__default__": + raise ValueError("function __default__ cannot be called") class keyword(VyperNode):