LuaLS / LuaLS/lua-language-server

cannot recognize emmy field

Open
#1,971 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feat/LuaCats Annotations question
Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

I have defined an emmy class role:

---@class role
---@field equipment_mgr equipment_mgr

an emmy class equipment_mgr:

---@class equipment_mgr
local data = {
        role = role, ---@type role
        equipment = orm_equipment, ---@type table<integer, db.Equipment>
}

then add some method to equipment_mgr:

---@type equipment_mgr
local mt = {}
mt.__index = mt

---@return db.Equipment
function mt:get_equipment(uid)
    return self.equipment[uid]
end

Lua Diagnostics cannot recognize the method get_equipment:
image

while other extension can

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the shown Lua class, field, metatable, and get_equipment method in Lua Diagnostics. Compare its recognition of the method with the other extension mentioned; done means Lua Diagnostics recognizes get_equipment on equipment_mgr without the reported diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.