From 4d45646bd94c790d9da7a3f09580fa328cd86024 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 03:38:42 +0000 Subject: [PATCH 1/3] Initial plan From 087446ed8db252c0c30c7f1070b7344b8055304a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 03:52:30 +0000 Subject: [PATCH 2/3] Fix crash in ElementList for TupleType and add test Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- internal/ast/ast.go | 2 ++ .../gen/inlayHintsTupleTypeCrash_test.go | 22 ++++++++++++++++ .../inlayHintsTupleTypeCrash.baseline | 25 +++++++++++++++++++ .../inlayHintsTupleTypeCrash.baseline.diff | 24 ++++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 internal/fourslash/tests/gen/inlayHintsTupleTypeCrash_test.go create mode 100644 testdata/baselines/reference/submodule/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline create mode 100644 testdata/baselines/reference/submodule/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline.diff diff --git a/internal/ast/ast.go b/internal/ast/ast.go index d2961d59c0..f0afbb925c 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -1068,6 +1068,8 @@ func (n *Node) ElementList() *NodeList { return n.AsNamedExports().Elements case KindObjectBindingPattern, KindArrayBindingPattern: return n.AsBindingPattern().Elements + case KindTupleType: + return n.AsTupleTypeNode().Elements } panic("Unhandled case in Node.ElementList: " + n.Kind.String()) diff --git a/internal/fourslash/tests/gen/inlayHintsTupleTypeCrash_test.go b/internal/fourslash/tests/gen/inlayHintsTupleTypeCrash_test.go new file mode 100644 index 0000000000..5df5b06667 --- /dev/null +++ b/internal/fourslash/tests/gen/inlayHintsTupleTypeCrash_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/ls/lsutil" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestInlayHintsTupleTypeCrash(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function iterateTuples(tuples: [string][]): void { + tuples.forEach((l) => {}) +}` + f := fourslash.NewFourslash(t, nil /*capabilities*/, content) + f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{ + IncludeInlayFunctionParameterTypeHints: true, + }) +} diff --git a/testdata/baselines/reference/submodule/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline b/testdata/baselines/reference/submodule/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline new file mode 100644 index 0000000000..c4db2d46ea --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline @@ -0,0 +1,25 @@ +// === Inlay Hints === + tuples.forEach((l) => {}) + ^ +{ + "position": { + "line": 1, + "character": 19 + }, + "label": [ + { + "value": ": " + }, + { + "value": "[" + }, + { + "value": "string" + }, + { + "value": "]" + } + ], + "kind": 1, + "paddingLeft": true +} \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline.diff b/testdata/baselines/reference/submodule/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline.diff new file mode 100644 index 0000000000..4b68d3baf3 --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/inlayHints/inlayHintsTupleTypeCrash.baseline.diff @@ -0,0 +1,24 @@ +--- old.inlayHintsTupleTypeCrash.baseline ++++ new.inlayHintsTupleTypeCrash.baseline +@@= skipped --1, +0 lines =@@ ++// === Inlay Hints === ++ tuples.forEach((l) => {}) ++ ^ ++{ ++ "label": [ ++ { ++ "value": ": " ++ }, ++ { ++ "value": "[" ++ }, ++ { ++ "value": "string" ++ }, ++ { ++ "value": "]" ++ } ++ ], ++ "kind": 1, ++ "paddingLeft": true ++} \ No newline at end of file From 5dd6ebe2ea019934d509c24b932bf028b2f07cd7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 04:10:00 +0000 Subject: [PATCH 3/3] Move test from gen to tests directory Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com> --- .../fourslash/tests/{gen => }/inlayHintsTupleTypeCrash_test.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename internal/fourslash/tests/{gen => }/inlayHintsTupleTypeCrash_test.go (100%) diff --git a/internal/fourslash/tests/gen/inlayHintsTupleTypeCrash_test.go b/internal/fourslash/tests/inlayHintsTupleTypeCrash_test.go similarity index 100% rename from internal/fourslash/tests/gen/inlayHintsTupleTypeCrash_test.go rename to internal/fourslash/tests/inlayHintsTupleTypeCrash_test.go