LuaLS / LuaLS/lua-language-server
Exact Class with `__index` Assignment Result in Loss of All Class Methods
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Windows
What is the issue affecting?
Completion, Hover
Expected Behaviour
Method :method and :method2 is shown.
Actual Behaviour
No method is shown.
Reproduction steps
Test code:
---@class (exact) Foo
local Foo = {}
Foo.__index = Foo ---@diagnostic disable-line inject-field
function Foo:method()
end
function Foo:method2(value)
end
---@return Foo
local function foo()
end
local b = foo()
Variable b has type of Foo. However typing b: won't show method and method2. The self variable inside Foo:nethod and Foo:method2 will also have same issue if used.
Removing the (exact) make it work works as expected. Removing the __index assignment also make it works as expected. However, silencing the __index inject field with ---@field __index Foo instead of using ---@diagnostic still result in same issue.
Hovering to b also won't show any of the methods. However hovering to Foo works.
Additional Notes
Typing the method name manually (e.g. :method2) will show completion normally and will make b show method2 after it's used once. But only method2 in that specific case. method still not be shown.
Log File
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
重现提供的 Lua 代码片段,并检查带有 __index 赋值的 exact 类的补全和悬停行为。以报告中 exact 类与 non-exact 类之间的差异作为比较的起点。当 Foo 方法在 b 和 self 的补全和悬停中出现,且不需要先输入方法名时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100