Skip to content

Signature help crash on call target when nested call has trailing comma #2312

@DanielRosenwasser

Description

@DanielRosenwasser

Had a hard time coming up with a minimal repro but here's the actual code it was found in.

https://github.com/microsoft/TypeScript/blob/1da8266179589bbc977ccbd8712614ed5ddd3004/src/services/navigationBar.ts#L681-L690

factory.createClassDeclaration/**/(

If you request signature help at the marker very quickly, you can trigger the following crash. This is tricky because it doesn't always happen. One way to often accomplish this in VS Code is to

  1. Trigger signature help (Ctrl+Shift+Space or just type , and delete it)
  2. Insert a stray character at the marker
  3. Immediately delete that stray character
error] panic handling requesttextDocument/signatureHelpruntime error: index out of range [5] with length 5goroutine 52857 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc0001e4008, 0xc047ef9620)
	github.com/microsoft/typescript-go/internal/lsp/server.go:701 +0x58
panic({0xca4c60?, 0xc039fbedb0?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/checker.(*Checker).getArgumentArityError(0xc04bddf308, 0xc04b108088, {0xc04bda8cc8, 0x1, 0xc001964c58?}, {0xc0544361a8, 0x5, 0x5?}, 0x0)
	github.com/microsoft/typescript-go/internal/checker/checker.go:9652 +0xa96
github.com/microsoft/typescript-go/internal/checker.(*Checker).reportCallResolutionErrors(0xc04bddf308, 0x109c2c0?, 0xc001964cf0, {0xc04bda8cc8, 0x1, 0x1}, 0x0)
	github.com/microsoft/typescript-go/internal/checker/checker.go:9540 +0x1f2
github.com/microsoft/typescript-go/internal/checker.(*Checker).resolveCall(0xc04bddf308, 0xc04b108088, {0xc04bda8cc8, 0x1, 0x1}, 0x0, 0x1f, 0x0, 0x0)
	github.com/microsoft/typescript-go/internal/checker/checker.go:8778 +0x605
github.com/microsoft/typescript-go/internal/checker.(*Checker).resolveCallExpression(0xc04bddf308, 0xc04b108088, 0x0, 0x1f)
	github.com/microsoft/typescript-go/internal/checker/checker.go:8405 +0x62d
github.com/microsoft/typescript-go/internal/checker.(*Checker).resolveSignature(0xc04bddfa60?, 0x109c2c0?, 0xc04b108088?, 0x85688e?)
	github.com/microsoft/typescript-go/internal/checker/checker.go:8292 +0x46
github.com/microsoft/typescript-go/internal/checker.(*Checker).getResolvedSignature(0xc04bddf308, 0xc04b108088, 0x0, 0x1f)
	github.com/microsoft/typescript-go/internal/checker/checker.go:8264 +0xd8
github.com/microsoft/typescript-go/internal/checker.(*Checker).checkCallExpression(0xc04bddf308, 0xc04b108088, 0x1f)
	github.com/microsoft/typescript-go/internal/checker/checker.go:8160 +0x4f
github.com/microsoft/typescript-go/internal/checker.(*Checker).checkExpressionWorker(0xc04bddf308, 0xc04b108088, 0x1f)
	github.com/microsoft/typescript-go/internal/checker/checker.go:7546 +0x2df
github.com/microsoft/typescript-go/internal/checker.(*Checker).checkExpressionEx(0xc04bddf308, 0xc04b108088, 0x1f)
	github.com/microsoft/typescript-go/internal/checker/checker.go:7334 +0x52
github.com/microsoft/typescript-go/internal/checker.(*Checker).checkExpressionWithContextualType(0xc04bddf308, 0xc04bdac900?, 0xc04cf1a770, 0xc04bdac700, 0x1c)
	github.com/microsoft/typescript-go/internal/checker/checker.go:7261 +0x22c
github.com/microsoft/typescript-go/internal/checker.(*Checker).inferTypeArguments(0xc04bddf308, 0xc04b1080e0, 0xc01cdfa100, {0xc0544361d0, 0x2, 0x2}, 0x1c, 0xc04bdac700)
	github.com/microsoft/typescript-go/internal/checker/checker.go:9345 +0x41e
github.com/microsoft/typescript-go/internal/checker.(*Checker).inferSignatureInstantiationForOverloadFailure(0xc04bddf308, 0xc04b1080e0, {0xc04bda8b48?, 0x3?, 0x781bb5?}, 0xc01cdfa100, {0xc0544361d0, 0x2, 0x2}, 0x10)
	github.com/microsoft/typescript-go/internal/checker/checker.go:9437 +0x93
github.com/microsoft/typescript-go/internal/checker.(*Checker).pickLongestCandidateSignature(0xc04bddf308, 0xc04b1080e0, {0xc04bda8b58, 0x1, 0xc04bda8b58?}, {0xc0544361d0, 0x2, 0x2}, 0x10)
	github.com/microsoft/typescript-go/internal/checker/checker.go:9395 +0x1d6
github.com/microsoft/typescript-go/internal/checker.(*Checker).getCandidateForOverloadFailure(0xc04bddf308, 0xc04b1080e0, {0xc04bda8b58, 0x1, 0x1}, {0xc0544361d0, 0x2, 0x2}, 0x1, 0x10)
	github.com/microsoft/typescript-go/internal/checker/checker.go:9365 +0xb4
github.com/microsoft/typescript-go/internal/checker.(*Checker).resolveCall(0xc04bddf308, 0xc04b1080e0, {0xc04bda8b50, 0x1, 0x1}, 0xc0019654f8, 0x10, 0x0, 0x0)
	github.com/microsoft/typescript-go/internal/checker/checker.go:8758 +0x53d
github.com/microsoft/typescript-go/internal/checker.(*Checker).resolveCallExpression(0xc04bddf308, 0xc04b1080e0, 0xc0019654f8, 0x10)
	github.com/microsoft/typescript-go/internal/checker/checker.go:8405 +0x62d
github.com/microsoft/typescript-go/internal/checker.(*Checker).resolveSignature(0xc04bddfa60?, 0x109c2c0?, 0xc04b1080e0?, 0x419225?)
	github.com/microsoft/typescript-go/internal/checker/checker.go:8292 +0x46
github.com/microsoft/typescript-go/internal/checker.(*Checker).getResolvedSignature(0xc04bddf308, 0xc04b1080e0, 0xc04bda14f8, 0x10)
	github.com/microsoft/typescript-go/internal/checker/checker.go:8264 +0xd8
github.com/microsoft/typescript-go/internal/checker.(*Checker).getResolvedSignatureWorker(0xc04bddf308, 0xc04b1080e0, 0x10, 0x3)
	github.com/microsoft/typescript-go/internal/checker/services.go:612 +0x27d
github.com/microsoft/typescript-go/internal/checker.GetResolvedSignatureForSignatureHelp.func1()
	github.com/microsoft/typescript-go/internal/checker/services.go:342 +0x25
github.com/microsoft/typescript-go/internal/checker.runWithoutResolvedSignatureCaching[...](0xc04bddf308?, 0xc052df2288, 0xc04bda1c78?)
	github.com/microsoft/typescript-go/internal/checker/services.go:365 +0x362
github.com/microsoft/typescript-go/internal/checker.GetResolvedSignatureForSignatureHelp(0xc04bda1d28?, 0xa4d81e?, 0xc04b108088?)
	github.com/microsoft/typescript-go/internal/checker/services.go:341 +0x45
github.com/microsoft/typescript-go/internal/ls.getCandidateOrTypeInfo(0xc04cf2cff0, 0xc04bddf308, 0xc04bddf308?, 0xc047febb00?, 0xeb?)
	github.com/microsoft/typescript-go/internal/ls/signaturehelp.go:673 +0x7b
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).GetSignatureHelpItems(0xc04bda4ab0, {0x10960c8, 0xc04bda4a50}, 0x67eb, 0xc022bf6400, 0xc047febb08, 0xc03ce42740)
	github.com/microsoft/typescript-go/internal/ls/signaturehelp.go:129 +0x21f
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideSignatureHelp(0xc04bda4ab0, {0x10960c8, 0xc04bda4a50}, {0xc02dff3800?, 0xc04bda4a50?}, {0x2dff3800?, 0xc0?}, 0xc03ce42740)
	github.com/microsoft/typescript-go/internal/ls/signaturehelp.go:48 +0x98
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleSignatureHelp(0x4776c5?, {0x10960c8?, 0xc04bda4a50?}, 0xc02dff3800?, 0xc019b686b8?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:990 +0x39
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].17({0x10960c8, 0xc04bda4a50}, 0xc047ef9620)
	github.com/microsoft/typescript-go/internal/lsp/server.go:617 +0x11a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc0001e4008, {0x1096100?, 0xc0291e8ff0?}, 0xc047ef9620)
	github.com/microsoft/typescript-go/internal/lsp/server.go:501 +0x14b
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:404 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 34
	github.com/microsoft/typescript-go/internal/lsp/server.go:424 +0x9ad

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions