Skip to content

[Bug]: Elixir: calls inside one-line function bodies (def f(x), do: g(x)) are never collected #4207

Description

@fayezzouari

Pre-flight checks

  • I have checked the Troubleshooting section in the README

What happened?

While working on a project, I found that calls inside keyword-form function bodies are missing from the graph. def a(x), do: b(x) produces the node a(), but no calls edge to b(), even though b is defined in the same module. One-line definitions are idiomatic Elixir (delegating wrappers, guards, small helpers), so a real code base loses a large share of its local call edges.

Where it happens (v8, graphify/extractors/elixir.py)

A function body is registered for walk_calls only when the definition has a do_block child (L252-253, if do_block_node: function_bodies.append(...)). The keyword form , do: expr has no do_block node. Its body is the value of the do: pair in the call's arguments keywords, so it is never walked.

Suggested fix

When a def/defp/defmacro/… has no do_block, take the value of the do: keyword in its arguments as the body and walk it the same way. The same applies to else:/rescue: keywords if they are handled for block bodies.

Steps to reproduce

mkdir -p repro2/lib && cd repro2
cat > lib/short.ex <<'EOF'
defmodule App.Short do
  def a(x), do: b(x)

  def b(x) do
    x
  end
end
EOF
uvx --python 3.13 --from graphifyy==0.9.80 graphify extract lib --code-only --no-cluster --out out
python3 -c "
import json
g = json.load(open('out/graphify-out/graph.json'))
print([(e['source'], e['target']) for e in g['edges'] if e['relation'] == 'calls'])
"

Error output or graph output

[]
expected: [('app_short_app_short_a', 'app_short_app_short_b')]

Graphify version

0.9.80

Operating System

macOS

Python Version

3.13

Installation Method

uv tool install (recommended)

Additional Environment Details

No provider environment variables set (--code-only, no LLM). Reproduced in a fresh directory containing only the four files above.

Additional context

No response

Activity

  1. github-actions commented on Oct 7, 2026

    @github-actions

    Thanks for opening this issue, @fayezzouari. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. Ayushraj06-bit commented on Oct 7, 2026

    @Ayushraj06-bit
    Contributor

    This is the same bug that #2970 (@rajatnagda45) fixes: it walks the do: keyword value as the function body when there's no do_block. That PR predates this issue, so it isn't linked here. It now conflicts with v8 and needs a rebase. The bug still reproduces on v8 (6478eb7): extractors/elixir.py only appends a function body when a do_block child exists.

  3. added a commit that references this issue on Oct 7, 2026
    b00d370
  4. added a commit that references this issue on Oct 8, 2026
    c36833d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions