typescript-go
typescript-go copied to clipboard
Completions crash in JSDoc object type literal
In a JS file:
/**
* @type {{/*$*/}}
*/
export let someVar = {};
Request completions at /*$*/.
[error] panic handling requesttextDocument/completionToken cache mismatch: parent. Expected parent of kind KindTypeLiteral, got KindTypeLiteralgoroutine 82693 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc000250008, 0xc0ab586090)
github.com/microsoft/typescript-go/internal/lsp/server.go:872 +0x58
panic({0xba49e0?, 0xc0ab606180?})
runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ast.(*SourceFile).GetOrCreateToken(0xc0a5c2c608, 0x12, 0xe, 0xf, 0xc0a74f2750)
github.com/microsoft/typescript-go/internal/ast/ast.go:10957 +0x305
github.com/microsoft/typescript-go/internal/astnav.findRightmostValidToken.func1(0xc0a74f2750, 0x10)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:534 +0x5cd
github.com/microsoft/typescript-go/internal/astnav.findRightmostValidToken(0xc0a74f2750?, 0xc0a5c2c608?, 0x2e?, 0xc0135999ba?, 0xc8?)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:561 +0x71
github.com/microsoft/typescript-go/internal/astnav.FindPrecedingTokenEx.func1(0xc0a74f2750)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:395 +0x271
github.com/microsoft/typescript-go/internal/astnav.FindPrecedingTokenEx.func1(0xc0a677f680)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:386 +0x22a
github.com/microsoft/typescript-go/internal/astnav.FindPrecedingTokenEx.func1(0xc0a6718f00)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:386 +0x22a
github.com/microsoft/typescript-go/internal/astnav.FindPrecedingTokenEx.func1(0xc0a6763300)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:386 +0x22a
github.com/microsoft/typescript-go/internal/astnav.FindPrecedingTokenEx.func1(0xc0a6659180)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:386 +0x22a
github.com/microsoft/typescript-go/internal/astnav.FindPrecedingTokenEx.func1(0xc0a5c2c608)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:386 +0x22a
github.com/microsoft/typescript-go/internal/astnav.FindPrecedingTokenEx(0x1?, 0xc073343d70?, 0x26?, 0x90?)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:405 +0x67
github.com/microsoft/typescript-go/internal/astnav.FindPrecedingToken(...)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:287
github.com/microsoft/typescript-go/internal/ls.getRelevantTokens(0xf, 0xc0a5c2c608)
github.com/microsoft/typescript-go/internal/ls/completions.go:2751 +0x2f
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionsAtPosition(0xc0ab6020f0, {0x107f7a8, 0xc0ab602090}, 0xc0a5c2c608, 0xf, 0x0)
github.com/microsoft/typescript-go/internal/ls/completions.go:337 +0x70
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCompletion(0xc0ab6020f0, {0x107f7a8, 0xc0ab602090}, {0xc0a8bd8f18?, 0xc0ab602090?}, {0xa8bd8f18?, 0xc0?}, 0xc0ab58a010)
github.com/microsoft/typescript-go/internal/ls/completions.go:44 +0xc8
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCompletion(0xc004bd0808?, {0x107f7a8?, 0xc0ab602090?}, 0xc0a8bd8f18?, 0x40b92c?)
github.com/microsoft/typescript-go/internal/lsp/server.go:1208 +0x39
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].16({0x107f7a8, 0xc0ab602090}, 0xc0ab586090)
github.com/microsoft/typescript-go/internal/lsp/server.go:621 +0x130
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc000250008, {0x107f7e0?, 0xc0ab608000?}, 0xc0ab586090)
github.com/microsoft/typescript-go/internal/lsp/server.go:502 +0x14b
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
github.com/microsoft/typescript-go/internal/lsp/server.go:405 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 9
github.com/microsoft/typescript-go/internal/lsp/server.go:425 +0x9ad
Also crashes outside the object in a typedef, might be a different bug technically.
/**
* @typedef {/**/{}} TypeName
*/
panic handling request textDocument/completion: Token cache mismatch: parent. Expected parent of kind KindTypeLiteral, got KindTypeLiteral
goroutine 2506 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc0001e4008, 0xc01507e120)
github.com/microsoft/typescript-go/internal/lsp/server.go:701 +0x4c
panic({0xbb8320?, 0xc013b7cde0?})
runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ast.(*SourceFile).GetOrCreateToken(0xc0116ef808, 0x12, 0x11, 0x12, 0xc0118c9560, 0x0)
github.com/microsoft/typescript-go/internal/ast/ast.go:10963 +0x2f4
github.com/microsoft/typescript-go/internal/astnav.getTokenAtPosition(0xc0116ef808, 0x11, 0x1, 0x0)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:198 +0x51b
github.com/microsoft/typescript-go/internal/astnav.GetTokenAtPosition(...)
github.com/microsoft/typescript-go/internal/astnav/tokens.go:40
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData(0xc013b93320, {0x109efa8, 0xc013b932c0}, 0xc003e63308, 0xc0116ef808, 0x11, 0xc004362500)
github.com/microsoft/typescript-go/internal/ls/completions.go:454 +0xce
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionsAtPosition(0xc013b93320, {0x109efa8, 0xc013b932c0}, 0xc0116ef808, 0x11, 0x0)
github.com/microsoft/typescript-go/internal/ls/completions.go:383 +0x2cf
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCompletion(0xc013b93320, {0x109efa8, 0xc013b932c0}, {0xc008150798?, 0xc013b932c0?}, {0x8150798?, 0xc0?}, 0xc015063510)
github.com/microsoft/typescript-go/internal/ls/completions.go:44 +0xc8
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCompletion(0xc001bd0008?, {0x109efa8?, 0xc013b932c0?}, 0xc008150798?, 0x40b92c?)
github.com/microsoft/typescript-go/internal/lsp/server.go:1011 +0x39
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].16({0x109efa8, 0xc013b932c0}, 0xc01507e120)
github.com/microsoft/typescript-go/internal/lsp/server.go:617 +0x130
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc0001e4008, {0x109efe0?, 0xc0131d3b80?}, 0xc01507e120)
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 18
github.com/microsoft/typescript-go/internal/lsp/server.go:424 +0x9ad