LuaLS / LuaLS/lua-language-server
lua-language-server not detecting types when destructuring Tuple types with ~table.unpack~
還沒有人認領這個 Issue。
- 主要語言
- Lua
- 星號
- 4.4k
- 分支
- 442
- PR 合併指標
- 30 天內沒有已合併 PR
描述
### How are you using the lua-language-server?
Other
### Which OS are you using?
Windows
### What is the issue affecting?
Diagnostics/Syntax Checking
### Expected Behaviour
I might be wrong here, but I assume this should work?
Language server should detect the types from the defined tuple:
```lua
---@alias my_tuple { [1]: integer, [2]: boolean }
---@type my_tuple
local tuple = {1, true}
--- This works!
local a, b = tuple[1], tuple[2]
--- This gets "integer" for "c", but "unknown" for "d:
local c, d = table.unpack(tuple)
```
### Actual Behaviour
```lua
---@alias my_tuple { [1]: integer, [2]: boolean }
---@type my_tuple
local tuple = {1, true}
--- "c" should be "integer" and "d" "boolean":
local c, d = table.unpack(tuple)
```
### Reproduction steps
1. Define tuple like I did
2. Create such tuple
3. `unpack` to two variables
### Additional Notes
I'm not sure if this is a feature that is even considered, but since I do use unpack sometimes to destructure tuples into their distinct variables, I feel this would be a good feature to have.
### Log File
_No response_
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先使用報告中的 tuple 和 table.unpack 範例重現問題,然後追蹤 language server 對 multiple assignment 和 unpacked tables 的型別推論。沒有指定原始碼檔案或測試;完成標準是該範例將 c 推論為 integer、將 d 推論為 boolean,同時不造成現有 tuple 診斷回歸。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- lua
- 領域
- tooling
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100