Skip to content

Method-to-class attribution breaks when two classes share a method name #21

Description

@DataDave-Dev

In src/lib/analysis/analyzers/shared.ts the methodClass map is keyed by method name only (Map<functionName, className>, line 80; methodClass.set(name, cls) line 105; lookup methodClass.get(name) line 245).

When two classes in the same file define a method with the same name (e.g. __init__, render, toString), the second overwrites the first, so the method node is attached to the wrong class. This is the common case in Python (every class has __init__).

Fix: key by a qualified id like `${cls}::${name}` (or invert the lookup). Add a test with two classes sharing a method name.


En src/lib/analysis/analyzers/shared.ts el mapa methodClass se indexa solo por el nombre del método (Map<nombreFunción, clase>, línea 80; set(name, cls) línea 105; lectura get(name) línea 245).

Si dos clases del mismo archivo definen un método con el mismo nombre (__init__, render, toString), la segunda pisa a la primera y el nodo queda asignado a la clase equivocada. Es el caso común en Python (todas las clases tienen __init__).

Fix: usar una clave cualificada tipo `${cls}::${name}` (o invertir la búsqueda). Añadir un test con dos clases que compartan método.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions