fix(fortran): emit calls edges for function invocations#1578
Closed
Synvoya wants to merge 1 commit into
Closed
Conversation
Function calls (`y = f(x)`) were silently dropped — only `subroutine_call` (`call sub(...)`) was handled in walk_calls. tree-sitter-fortran represents a function invocation as a `call_expression`, which had no branch, so every function-to-function call produced no edge. Handle `call_expression`. Because Fortran uses the same `name(...)` syntax for array indexing, the callee is resolved against procedures defined in the file (`target_nid in seen_ids`) before emitting — so array accesses like `arr(i)` cannot fabricate spurious `calls` edges. Adds a function + caller to the fixture and a regression test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
safishamsi
added a commit
that referenced
this pull request
Jul 1, 2026
Collaborator
|
Merged into |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fortran function calls (
y = f(x)) emit nocallsedge. Onlycall sub(...)(subroutine) calls were captured.Root cause
walk_callshandledsubroutine_callbut notcall_expression, which is how tree-sitter-fortran represents a function invocation:So every function-to-function call was dropped.
Fix
Handle
call_expression. Fortran uses the samename(...)syntax for array indexing (arr(i)), so — unlikesubroutine_call— the callee is resolved against procedures defined in the file (target_nid in seen_ids) before emitting. Array accesses whose name isn't a defined procedure produce no edge, so they can't fabricate spuriouscalls.Verification
f = g()-> calls(f, g);call sub()still works;arr(3)array access -> no edge.pytest tests/test_languages.py-> 300 passed, 13 skipped (13 fortran).ruff check-> clean.