Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Scala: given...with instance methods leak to the file and collide with same-named trait methods

Open
#4,130 1 comment 0 reactions 0 assignees View on GitHub

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
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python, scala
Domain
devtools

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 intShow node owning show/helper; the show -> helper call stays inside the given; the trait node is untouched.
  • Actual: no given node; methods leak to the file; the trait show node 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Graphify-Labs/graphify

All issues in Graphify-Labs/graphify

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.