Skip to content

Completions crash in JSDoc object type literal #2289

@DanielRosenwasser

Description

@DanielRosenwasser

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions