Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Comments before parameters interfere with argument name resolution聽#371

Closed

Description

@robrix
let obj = {
    x: 1
};

function func_7(/**/ o) {
    return o;
}

func_7(obj).x;
//          ^ defined: 2

This test fails (but should pass) because the comment steals the parameter's lunch.

馃帺 @BekaValentine

Activity

  1. BekaValentine commented on Jan 29, 2024

    @BekaValentine
    Contributor

    The problem with this one is that the comment before o is a child of the parameter list that's distinct from the parameter itself. So the comment is child 1 while the param is child 2. The lookup on on x goes through the fall func_7(obj), which sets up a scope where obj is the 1th argument, and the parameter list sets up a lookup on those arguments based on the position of the child. Except in this case, o is not the 1th child, so it resolves to the wrong place -- the non-existent 2th argument of the call.

    I can't see any way to fix this within the current tree-sitter framework.

  2. CleanCut commented on Sep 9, 2025

    @CleanCut

    The github/stack-graphs repository is no longer being maintained. As per #502, I'm closing all issues and pull requests before archiving the repository.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions