Skip to content

fix(fortran): emit calls edges for function invocations#1578

Closed
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/fortran-function-call-edges
Closed

fix(fortran): emit calls edges for function invocations#1578
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/fortran-function-call-edges

Conversation

@Synvoya

@Synvoya Synvoya commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Fortran function calls (y = f(x)) emit no calls edge. Only call sub(...) (subroutine) calls were captured.

Root cause

walk_calls handled subroutine_call but not call_expression, which is how tree-sitter-fortran represents a function invocation:

assignment_statement
  identifier "x"
  call_expression        <-- unhandled
    identifier "compute"

So every function-to-function call was dropped.

Fix

Handle call_expression. Fortran uses the same name(...) syntax for array indexing (arr(i)), so — unlike subroutine_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 spurious calls.

Verification

  • f = g() -> calls(f, g); call sub() still works; arr(3) array access -> no edge.
  • Added a function + caller to the fixture and a regression test.
  • pytest tests/test_languages.py -> 300 passed, 13 skipped (13 fortran).
  • ruff check -> clean.

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
…, #1579)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@safishamsi

Copy link
Copy Markdown
Collaborator

Merged into v8 as b8f41c7 (your authorship). The array-indexing guard is the right call and it holds — adversarial smoke confirmed z = dbl(a) emits a call while z = arr(3) (same name(...) syntax) does not. Full suite 2774. Ships next release.

@safishamsi safishamsi closed this Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants