Scala: given...with instance methods leak to the file and collide with same-named trait methods
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #4131 by @rajatnagda45 — closed without merging
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
Research direction
Start by reading the Scala extraction path exposed as extract_scala and how class_types handles given_definition and with_template_body. Use the given.scala reproduction to check the graph. Done means intShow owns show and helper, the call stays within the given, and the trait's show node is untouched.
Written by the indexing model from the issue text.
Description
Version / commit
v0.9.77 (v8 @ 5c7b847)
Environment
macOS, Python 3.13, clean checkout of v8.
What happens
A Scala 3 given name: T with { ... } instance owns method implementations, but it is not modelled as a container. Its methods leak to the file node, and when a given method shares a name with a method of the trait it implements (the normal case — it IS the implementation), the leaked file-level node collides with the trait's method node. The trait node then wrongly carries the given's call/reference edges, corrupting the graph.
Minimal reproduction
// given.scala
trait Show[A]:
def show(a: A): String
given intShow: Show[Int] with
def show(a: Int): String = helper(a)
def helper(a: Int): String = a.toString
from graphify.extract import extract_scala
r = extract_scala("given.scala")
print([n["label"] for n in r["nodes"]])
# -> no 'intShow' node; a stray file-level 'helper' appears
print([(e["source"], e["target"]) for e in r["edges"] if e["relation"] == "calls"])
# the show -> helper call is attributed to the TRAIT's show node, not the given's
Expected vs actual
- Expected: an
intShownode owningshow/helper; theshow -> helpercall stays inside the given; the trait node is untouched. - Actual: no given node; methods leak to the file; the trait
shownode is polluted with the given's edges.
Root cause
given_definition is absent from the Scala class_types, so the engine never opens a scope for its with_template_body; the members are walked as if they were file-level definitions and their ids collide with equally-named trait members.
A clean checkout of v8 reproduces it. Fix PR to follow.
- Dominant language
- Python
- Stars
- 124k
- Forks
- 11.9k
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Graphify-Labs/graphify
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Graphify-Labs/graphify#3763 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Graphify-Labs/graphify#3611 · 1 comment ·
Maintainers usually reply within 1 day
-
Nix supportOpen
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Graphify-Labs/graphify#3193 · 2 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Graphify-Labs/graphify#2871 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Graphify-Labs/graphify#2865 ·
Maintainers usually reply within 1 day
All issues in Graphify-Labs/graphify
Similar issues
-
customer-reported question
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Azure/azure-sdk-for-python#49548 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
btclib-org/btclib-wallet#409 ·
Maintainers usually reply within 1 day
-
Phase 2 PSA Capability & Career Profile
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
fastmachinelearning/hls4ml#1582 ·
Maintainers usually reply within 3 days
-
Sort modelsOpenenhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day