Skip to content

Fix instantiation expr. args. in TypeScript. #483

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bm-w
Copy link

@bm-w bm-w commented Apr 3, 2025

instantiation_expression syntax nodes were not included in the list of basic expressions, and thus the @expr.lexical_scope graph node was not being created for them. This caused an error in the stanza that deals with function arguments, e.g.:

0: Error executing statement edge @arg.lexical_scope -> @args.lexical_scope at (3515, 3)
     src/stack-graphs.tsg:3515:3:
     3515 |   edge @arg.lexical_scope -> @args.lexical_scope
          |   ^
     in stanza
     src/stack-graphs.tsg:3511:1:
     3511 | (arguments (_)@arg)@args {
          | ^
     matching (arguments) node
     test/test.ts:3:4:
     3 | foo(Bar<string>);
       |    ^
1: Evaluating edge source
2: Undefined scoped variable [syntax node instantiation_expression (3, 5)].lexical_scop

Simply including instantiation_expression syntax nodes in the list fixe the issue. Copious testing (on our TS test suite and on all of microsoft/vscode) reveals no negative side effects.

Actually resolving a reference appearing in an instantiation expression as call argument does not work — I left a TODO.

@Copilot Copilot AI review requested due to automatic review settings April 3, 2025 14:37
@bm-w bm-w requested review from a team as code owners April 3, 2025 14:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where instantiation_expression syntax nodes were not included in the list of basic expressions, causing errors when handling function argument lexical scopes.

  • Added a new test file to verify that instantiation expressions are properly handled.
  • The new test confirms that the fix resolves the error when using instantiation expressions as call arguments.
Files not reviewed (1)
  • languages/tree-sitter-stack-graphs-typescript/src/stack-graphs.tsg: Language not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant