Skip to content

[Bug]: PowerShell member calls bind to another class with the same method name #4158

Description

@oleksii-tumanov

Pre-flight checks

  • I have checked the Troubleshooting section in the README

What happened?

When two PowerShell classes define the same method name, $this.Pick() in Alpha.Run produces a definite call edge to Beta.Pick. This makes the graph show a dependency on the wrong class.

The expected call is Alpha.Run -> Alpha.Pick. Member calls should retain the receiver's class identity; a receiver that cannot be established should remain unresolved rather than selecting another class by method name.

Steps to reproduce

Save the following as two_classes.ps1:

class Alpha {
 [int] Pick() { return 1 }
 [int] Run() { return $this.Pick() }
}
class Beta {
 [int] Pick() { return 2 }
 [int] Run() { return $this.Pick() }
}

Run the source extractor directly, without an AST cache:

from pathlib import Path
from graphify.extractors.powershell import extract_powershell

result = extract_powershell(Path("two_classes.ps1"))
for edge in result["edges"]:
    if edge.get("relation") == "calls":
        print(edge["source"], "->", edge["target"])

Compare the class-qualified node IDs, since both method nodes have the label .Pick().

Error output or graph output

Class-normalized call edges from the real source extractor:

Alpha.Run -> Beta.Pick  (EXTRACTED)
Beta.Run -> Beta.Pick   (EXTRACTED)

The fixture parses without tree-sitter errors. An explicit [Alpha]::Make() likewise selects Beta.Make when both classes declare Make.

Graphify version

0.9.77; tested source 5c7b84792f453582676548185aaec3824d51dfe2 on v8.

Operating System

macOS

Python Version

3.12

Installation Method

built from source (git clone)

Additional Environment Details

Python 3.12.11, tree-sitter 0.25.2 and tree-sitter-powershell 0.26.4, using a source snapshot with local dependencies. PowerShell source is parsed, not executed. The direct extractor probe bypasses the corpus AST cache and needs no model request.

Additional context

#3992 and #3995 fixed previously dropped member calls; that fix is present. This report concerns the remaining receiver-identity error, not missing PowerShell support. Variable type inference, cross-file dispatch and bare-command/function name collisions are separate scope.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions