Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#4,130 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

  • #4131 de @rajatnagda45 — cerrado sin fusionar

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python, scala
Área
devtools

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
124k
Forks
11.9k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Graphify-Labs/graphify

Todos los issues de Graphify-Labs/graphify

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.