LuaLS / LuaLS/lua-language-server
Proposal consider vararg returns as forced optional
まだ誰も着手していません。
- 主要言語
- 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?
Diagnostics/Syntax Checking
Expected Behaviour
I suggest consider vararg returns as optional (can be nil) because no one guarantees that they will be filled in. The same goes for arguments, despite the fact that their type can also be optional or nilable.
If we return at least something, but we don't know the quantity, then the first argument won't be vararg - any, any ....
Thus after that we do not need to additionally specify that the vararg returns is optional.
---@param a string
function test(a) end
---@param ... string
---@return string ...
function f(...) end
local a, b, c = f() --no warn
local a, b, c = f("1")
test(a) --no warn, expected optinal cannot match
---@param ... string?
---@return string? ...
function f(...) end
local a, b, c = f() --no warn
local a, b, c = f("1")
test(a) --warn optinal cannot match
---@param ... string|nil
---@return string|nil ...
function f(...) end
local a, b, c = f() --no warn
local a, b, c = f("1")
test(a) --warn nil cannot match
Actual Behaviour
Vararg arguments are optional, but vararg returns are not.
Reproduction steps
- Make vararg return of some existing type.
- It is guaranteed to be infinite - not optional or nil.
Additional Notes
No response
Log File
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Lua language server の vararg 引数と戻り値に対する診断および型推論の処理から始め、再現手順と例を動作の指針として使用します。vararg の戻り値が適切に optional または nilable として扱われることを確認し、提示された呼び出しがそれぞれ期待される警告と警告なしの結果を生成することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100