LuaLS / LuaLS/lua-language-server
Generics Return Issue
オープン
まだ誰も着手していません。
enhancement
feat/generic
- 主要言語
- 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?
Annotations
Expected Behaviour
In this function:
--- Merge two tables together, keys that are the same will use the value from the second table
---@generic K, V, L, W
---@param table1 table<K, V>
---@param table2 table<L, W>
---@return table<K | L, V | W>
function table.merge(table1, table2)
for k, v in pairs(table2) do
table1[k] = v
end
return table1
end
I would expect the return type to be table<K | L, V | W> however it is actually always table<K, V>
There is also a secondary issue here where k, v are seen as unknown when they should be seen as V, W (I assume this is another generics issue)
Actual Behaviour
Reproduction steps
- Copy example code
- Observe result
Additional Notes
No response
Log File
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Windows 上の Visual Studio Code 拡張機能で、注釈付きの table.merge 例を再現します。まず、@generic、@param、@return、pairs に対するジェネリック注釈とテーブル型推論を追跡します。完了条件は、戻り値が table<K | L, V | W> となり、k と v が 2 番目のテーブルの型に解決されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua, vscode
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100