Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

Adds a regression test for issue #2460 where textDocument/inlayHint panics on reparsed AST nodes (specifically reparsed function expressions in JavaScript module exports).

Test coverage:

  • New TestInlayHintsOnModuleExportsWithFunctionExpression (in inlayHintsInJavaScriptCjsFile_test.go) reproduces the crash scenario
  • Passes with the existing fix (checking NodeFlagsReparsed)
  • Fails without the fix with: "Cannot create token from reparsed node of kind KindFunctionExpression"

The test case:

// @allowJs: true
// @checkJs: true
// @Filename: /a.js
module.exports = function () {
  return 1;
};

Follows the pattern of existing fourslash-based inlay hint tests. Test is placed in internal/fourslash/tests/ as a new regression test for typescript-go.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix inlay hint issue with reparsed nodes Add regression test for inlay hints crash on reparsed nodes Jan 27, 2026
@DanielRosenwasser DanielRosenwasser marked this pull request as ready for review January 27, 2026 21:24
Base automatically changed from fix-2460 to main January 27, 2026 21:40
@@ -0,0 +1,18 @@
--- old.inlayHintsCrashReparsed.baseline
+++ new.inlayHintsCrashReparsed.baseline
Copy link
Member

Choose a reason for hiding this comment

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

Why is this getting a diff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in commit 28b2b1b. The .diff file was inappropriately generated for a new test - diff files are only for tests ported from TypeScript to show behavioral differences.

Copy link
Member

Choose a reason for hiding this comment

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

@copilot Rename test to

inlayHintsInJavaScriptCjsFile._test.go

Copy link
Member

Choose a reason for hiding this comment

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

Also, is this the right directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 28b2b1b. Renamed test file to inlayHintsInJavaScriptCjsFile_test.go and kept it in the manual directory since it's a manually created test (not ported from TypeScript).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the manual directory is appropriate for this test. Tests in manual/ are manually created (not ported from TypeScript), and tests in gen/ are automatically generated from TypeScript's fourslash tests. This is a new regression test specific to typescript-go, so it belongs in manual/.

Copy link
Member

Choose a reason for hiding this comment

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

Wrong, manual are for generated tests that have been "promoted" to a handwritten onr

Copy link
Member

Choose a reason for hiding this comment

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

@copilot obey.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to gen/ directory in commit 64d56f3.

Copy link
Member

Choose a reason for hiding this comment

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

No, they go in tests directly

Copy link
Member

Choose a reason for hiding this comment

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

@copilot try again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to tests/ directory in commit 787b4bd.

"github.com/microsoft/typescript-go/internal/testutil"
)

func TestInlayHintsCrashReparsed(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func TestInlayHintsCrashReparsed(t *testing.T) {
func TestInlayHintsOnModuleExportsWithFunctionExpression(t *testing.T) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 28b2b1b.

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.

4 participants