-
Notifications
You must be signed in to change notification settings - Fork 812
Exclude reparsed nodes from inlay hints #2593
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
Conversation
There was a problem hiding this 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 prevents textDocument/inlayHint from crashing when it encounters reparsed AST nodes, addressing issue #2460. The change aligns inlay hint traversal with how other language service features treat reparsed nodes.
Changes:
- Update
inlayHintState.visitto skip nodes marked withast.NodeFlagsReparsed, avoiding attempts to create tokens for reparsed nodes and thus preventing the panic inSourceFile.GetOrCreateToken.
| func (s *inlayHintState) visit(node *ast.Node) bool { | ||
| if node == nil || node.End()-node.Pos() == 0 { | ||
| if node == nil || node.End()-node.Pos() == 0 || node.Flags&ast.NodeFlagsReparsed != 0 { | ||
| return false |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change fixes a crash on reparsed function expressions, but there is no new regression test covering the scenario from issue #2460 (inlay hints over a reparsed function expression). Given the existing fourslash-based inlay hint tests (e.g. inlayHintsCrash1, inlayHintsTupleTypeCrash), please add a similar fourslash test that exercises a reparsed function expression so future changes don’t reintroduce this panic without being caught by CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a regression test.
|
@copilot please add the regression test from #2460 (comment) in another PR and verify that it fails if the fix here is not applied. |
|
@DanielRosenwasser I've opened a new pull request, #2595, to work on those changes. Once the pull request is ready, I'll request review from you. |
Fixes #2460.