Given the following four files, language server behavior in d.lua works as expected until c.lua is opened (i.e. didOpen is sent via LSP), at which point GlobalTable.Namespace loses type information and becomes just unknown.
a.lua
---@meta
GlobalTable = {}
b.lua
_G.GlobalTable = _G.GlobalTable or {}
c.lua
GlobalTable.Namespace = {}
GlobalTable.Namespace.Var = 1
d.lua
local v = GlobalTable.Namespace.Var
This misbehavior has been reproduced in emmylua_ls 0.24.0 and 0.25.0 within the VSCode extension, and also through a LLM-generated LSP client communicating directly with emmylua_ls 0.25.0 while reducing this to a test case.
I originally encountered this problem when working with https://github.com/beyond-all-reason/Beyond-All-Reason/blob/92b74af2ba0347ebcef739b8956b9ee6921f44f3/spec/spec_helper.lua#L41.
Given the following four files, language server behavior in
d.luaworks as expected untilc.luais opened (i.e.didOpenis sent via LSP), at which pointGlobalTable.Namespaceloses type information and becomes justunknown.a.luab.luac.luad.luaThis misbehavior has been reproduced in emmylua_ls 0.24.0 and 0.25.0 within the VSCode extension, and also through a LLM-generated LSP client communicating directly with emmylua_ls 0.25.0 while reducing this to a test case.
I originally encountered this problem when working with https://github.com/beyond-all-reason/Beyond-All-Reason/blob/92b74af2ba0347ebcef739b8956b9ee6921f44f3/spec/spec_helper.lua#L41.