typescript-go
typescript-go copied to clipboard
Panic when retrieving namespace information in `textDocument/definition`
I'm just a user so please feel free to ask for more context if I missed something.
Effect exports a number of namespaces from the main package for easy access. Normal usage is like this:
import { Console, Effect, Option, Schema } from "effect";
These are basically just exposed from a bunch of smaller sub-packages. For example, this works as intended:
For some reason using the former syntax causes a panic. I'm afraid I have no insight as to why exactly but it's pretty easy to reproduce which I have provided bellow.
Stack trace
[13:46:54.368] Updated watches in 18.208µs
panic handling request textDocument/definition runtime error: invalid memory address or nil pointer dereference goroutine 120069 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x64
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0x1400010cdc0, 0x14018677680)
github.com/microsoft/typescript-go/internal/lsp/server.go:542 +0x44
panic({0x100a6e8e0?, 0x10120bde0?})
runtime/panic.go:783 +0x120
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getMappedLocation(0x1401a9a9110, {0x14002f83b30, 0x43}, {0x780350?, 0x1?})
github.com/microsoft/typescript-go/internal/ls/source_map.go:21 +0x4c
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).createLocationsFromDeclarations(0x1401a9a9110, {0x1400e3aedb0, 0x1, 0x140308df208?})
github.com/microsoft/typescript-go/internal/ls/definition.go:108 +0x114
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideDefinition(0x1401a9a9110, {0x100c54d90, 0x1405ba7fcc0}, {0x1405a930700?, 0x14000827e48?}, {0x472f44?, 0x1?})
github.com/microsoft/typescript-go/internal/ls/definition.go:57 +0x314
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleDefinition(0x140002ec000?, {0x100c54d90?, 0x1405ba7fcc0?}, 0x1405a930700?, 0x39?)
github.com/microsoft/typescript-go/internal/lsp/server.go:766 +0x38
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].13({0x100c54d90, 0x1405ba7fcc0}, 0x14018677680)
github.com/microsoft/typescript-go/internal/lsp/server.go:528 +0xf0
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0x1400010cdc0, {0x100c54d90, 0x1405ba7fcc0}, 0x14018677680)
github.com/microsoft/typescript-go/internal/lsp/server.go:425 +0xf4
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
github.com/microsoft/typescript-go/internal/lsp/server.go:330 +0x34
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 34
github.com/microsoft/typescript-go/internal/lsp/server.go:350 +0x6f8
[Error - 13:47:03] Request textDocument/definition failed.
Message: InternalError: panic handling request textDocument/definition: runtime error: invalid memory address or nil pointer dereference
Code: -32603
Steps to reproduce
- Install the Effect TS library (using bun if that matters)
- Import any namespace from the main package. e.g.
import { Console, Effect, Option, Schema } from "effect"; - Hold
metaand mouse over any of the namespaces. - Panic!