diff --git a/tests/functional/semantics/analysis/test_cyclic_function_calls.py b/tests/functional/semantics/analysis/test_cyclic_function_calls.py index 086f8ed08c..2a09bd5ed5 100644 --- a/tests/functional/semantics/analysis/test_cyclic_function_calls.py +++ b/tests/functional/semantics/analysis/test_cyclic_function_calls.py @@ -6,6 +6,18 @@ from vyper.semantics.analysis.module import ModuleAnalyzer +def test_self_function_call(namespace): + code = """ +@internal +def foo(): + self.foo() + """ + vyper_module = parse_to_ast(code) + with namespace.enter_scope(): + with pytest.raises(CallViolation): + ModuleAnalyzer(vyper_module, {}, namespace) + + def test_cyclic_function_call(namespace): code = """ @internal diff --git a/vyper/semantics/analysis/module.py b/vyper/semantics/analysis/module.py index 3907882e7a..188005e365 100644 --- a/vyper/semantics/analysis/module.py +++ b/vyper/semantics/analysis/module.py @@ -117,11 +117,6 @@ def __init__( # anything that is not a function call will get semantically checked later calls_to_self = calls_to_self.intersection(function_names) self_members[node.name].internal_calls = calls_to_self - if node.name in self_members[node.name].internal_calls: - self_node = node.get_descendants( - vy_ast.Attribute, {"value.id": "self", "attr": node.name} - )[0] - raise CallViolation(f"Function '{node.name}' calls into itself", self_node) for fn_name in sorted(function_names): if fn_name not in self_members: