Skip to content

Folding range crash in JS file for exports.property = CallExpression(ObjectLiteral) #2245

@DanielRosenwasser

Description

@DanielRosenwasser
exports.Something = make({
});
panic handling request textDocument/foldingRange Token cache mismatch: parent. Expected parent of kind KindCallExpression, got KindCallExpression goroutine 35780 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc0001e4008, 0xc011f70a20)
	github.com/microsoft/typescript-go/internal/lsp/server.go:880 +0x58
panic({0xba2920?, 0xc0130a2540?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ast.(*SourceFile).GetOrCreateToken(0xc000dad208, 0x4f, 0x883, 0x883, 0xc000dac818)
	github.com/microsoft/typescript-go/internal/ast/ast.go:10957 +0x305
github.com/microsoft/typescript-go/internal/astnav.FindChildOfKind.func1(0xc01f7bfe00)
	github.com/microsoft/typescript-go/internal/astnav/tokens.go:693 +0xce
github.com/microsoft/typescript-go/internal/ast.visitNodes(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:28
github.com/microsoft/typescript-go/internal/ast.visitNodeList(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:37
github.com/microsoft/typescript-go/internal/ast.(*CallExpression).ForEachChild(0xc000dac818, 0xc01bb3b6c0)
	github.com/microsoft/typescript-go/internal/ast/ast.go:6847 +0xff
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ast.ForEachChildAndJSDoc(0xc000dad208?, 0x875?, 0xc001353870?)
	github.com/microsoft/typescript-go/internal/ast/utilities.go:2871 +0x43
github.com/microsoft/typescript-go/internal/astnav.FindChildOfKind(0xc000dac818, 0x14, 0xc000dad208)
	github.com/microsoft/typescript-go/internal/astnav/tokens.go:711 +0xf9
github.com/microsoft/typescript-go/internal/ls.spanForCallExpression(0xc000dac818, 0xc000dad208, 0xc00c9fe000)
	github.com/microsoft/typescript-go/internal/ls/folding.go:404 +0x65
github.com/microsoft/typescript-go/internal/ls.getOutliningSpanForNode(0x107cdc8?, 0xc01171ff20?, 0xc00c9fe000?)
	github.com/microsoft/typescript-go/internal/ls/folding.go:361 +0x17b
github.com/microsoft/typescript-go/internal/ls.visitNode({0x107cdc8, 0xc01171ff20}, 0xc000dac818, 0x26, 0xc000dad208, 0xc00c9fe000)
	github.com/microsoft/typescript-go/internal/ls/folding.go:151 +0x8d8
github.com/microsoft/typescript-go/internal/ls.visitNode.func1(0x419225?)
	github.com/microsoft/typescript-go/internal/ls/folding.go:194 +0x3d
github.com/microsoft/typescript-go/internal/ast.visit(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:21
github.com/microsoft/typescript-go/internal/ast.(*BinaryExpression).ForEachChild(0xc0050eb960, 0xc01bb3b580)
	github.com/microsoft/typescript-go/internal/ast/ast.go:6280 +0xf1
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ls.visitNode({0x107cdc8, 0xc01171ff20}, 0xc0050eb960, 0x27, 0xc000dad208, 0xc00c9fe000)
	github.com/microsoft/typescript-go/internal/ls/folding.go:200 +0xff7
github.com/microsoft/typescript-go/internal/ls.visitNode.func1(0xc00c9fe001?)
	github.com/microsoft/typescript-go/internal/ls/folding.go:194 +0x3d
github.com/microsoft/typescript-go/internal/ast.visit(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:21
github.com/microsoft/typescript-go/internal/ast.(*ExpressionStatement).ForEachChild(0xc00e2f5490?, 0xc01bb3abc0?)
	github.com/microsoft/typescript-go/internal/ast/ast.go:3635 +0x23
github.com/microsoft/typescript-go/internal/ast.(*Node).ForEachChild(...)
	github.com/microsoft/typescript-go/internal/ast/ast.go:242
github.com/microsoft/typescript-go/internal/ls.visitNode({0x107cdc8, 0xc01171ff20}, 0xc018ab8d80, 0x28, 0xc000dad208, 0xc00c9fe000)
	github.com/microsoft/typescript-go/internal/ls/folding.go:200 +0xff7
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).addNodeOutliningSpans(0xc00c9fe000, {0x107cdc8, 0xc01171ff20}, 0xc000dad208)
	github.com/microsoft/typescript-go/internal/ls/folding.go:40 +0x41b
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideFoldingRange(0xc00c9fe000, {0x107cdc8, 0xc01171ff20}, {0xc01219cbd0?, 0x89?})
	github.com/microsoft/typescript-go/internal/ls/folding.go:20 +0x6f
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleFoldingRange(0x4776c5?, {0x107cdc8?, 0xc01171ff20?}, 0xc01219cbd0?, 0xc0032d5208?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:1177 +0x2b
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].29({0x107cdc8, 0xc01171ff20}, 0xc011f70a20)
	github.com/microsoft/typescript-go/internal/lsp/server.go:629 +0x11a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc0001e4008, {0x107ce00?, 0xc00cafa500?}, 0xc011f70a20)
	github.com/microsoft/typescript-go/internal/lsp/server.go:510 +0x153
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:413 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 10
	github.com/microsoft/typescript-go/internal/lsp/server.go:433 +0x9ad

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions