LuaLS / LuaLS/lua-language-server
Overload type narrowing based on number of arguments instead of argument-type
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
With the following code:
```
---@overload fun(param1: "test", param2: string)
---@overload fun(param1: "test2", param2: number)
---@overload fun(param1: "test3", param2: boolean, param3: number)
local function test(...)
end
test("test", "string"); ---expected: good, actual: good
test("test2", 1); ---expected: good, actual: good
test("test3", true, 1); ---expected: good, actual: good
test("test", 1); ---expected: bad, actual: good
test("test2", "string"); ---expected: bad, actual: good
test("test", true, 2) ---expected: bad, actual: bad
test("test3", "string"); ---expected: bad, actual: bad
test("test3", "string", 1); ---expected: bad, actual: bad
test("test3", true); ---expected: bad, actual: bad
```
I get the following errors:
With these overloads I would of expected the type to be equivalent to this:
```
{
param1: "test"
param2: string
} | {
param1: "test2"
param2: number
} | {
param1: "test3"
param2: boolean
param3: number
}
```
However, it is actually equivalent to:
```
{
param1: "test" | "test2"
param2: string | number
} |
{
param1: "test3"
param2: boolean
param3: number
}
```
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず issue のオーバーロード例を再現し、オーバーロードされた関数呼び出しに対する language server の型チェック経路を追跡します。修正が完了するのは、引数の型によって引数の個数と同様にオーバーロードが絞り込まれ、示されている3つの有効な呼び出しが受け入れられ、不一致の呼び出しが拒否されるようになったときです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100