LuaLS / LuaLS/lua-language-server
A key and value of the nested table are not defined
還沒有人認領這個 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?
Other
### Expected Behaviour



### Actual Behaviour



### Reproduction steps
Maybe I'm doing something wrong, but it seems to have worked before
```lua
---@class Test
---@field ID integer
local Test = {};
---@param id integer
---@return Test
function Test:new(id)
return setmetatable({ ID = id }, { __index = self });
end
---@type table >
local tab = {
[1] = { 1.0, 2.1, 3.2 },
[2] = { 4.0, 5.1, 6.2 },
[3] = { 7.0, 8.1, 9.2 }
}
---@generic T
---@param test table
---@return table
local function convert2Test(test)
local t = {};
for k, v in pairs(test) do
t[Test:new(k)] = v;
end
return t;
end
local newTab = convert2Test(tab);
for k, v in pairs(newTab) do
print(k, v); -- ok! k and v detected
end
local test = Test:new(3);
local info = newTab[test];
if info then
for k, v in pairs(info) do
print(k, v); -- oops! k and v not detected
end
end
```
### Additional Notes
_No response_
### Log File
_No response_
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 issue 中的 Lua 重現開始,比較預期和實際螢幕擷取畫面中的推斷型別。調查用於 tab 的巢狀表格型別,以及透過 convert2Test 傳回的值。當內層表格的鍵型別和值型別在最終的 pairs 迴圈中被推斷出來時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- lua
- 領域
- devtools
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100