Skip to content

Type information lost when file adding a member to a global table is opened (LSP didOpen) #1218

Description

@sparr

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.

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