Skip to content

Commit

Permalink
chore: remove duplicate check for a function call into itself (vyperl…
Browse files Browse the repository at this point in the history
…ang#3357)

A function that calls itself is already caught in `_find_cyclic_call`.
This PR removes a duplicate check.
  • Loading branch information
tserg authored May 15, 2023
1 parent c202c4e commit f450cb1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 12 additions & 0 deletions tests/functional/semantics/analysis/test_cyclic_function_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions vyper/semantics/analysis/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f450cb1

Please sign in to comment.