Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments before parameters interfere with argument name resolution #371

Open
robrix opened this issue Jan 16, 2024 · 1 comment
Open

Comments before parameters interfere with argument name resolution #371

robrix opened this issue Jan 16, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@robrix
Copy link
Contributor

robrix commented Jan 16, 2024

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

@robrix robrix added the bug Something isn't working label Jan 16, 2024
@BekaValentine
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants