LuaLS / LuaLS/lua-language-server
Question mark optional syntax not supported in fun() declarations
オープン
まだ誰も着手していません。
- 主要言語
- 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?
Type Checking
Expected Behaviour
Optional value to actually be optional
Actual Behaviour
It's not optional.
This code block should show as Human? and throw warnings for not checking nil. If I manually annotate with ---@param man Human? this works as expected.
The class in question:
---@class Command
---@field info string What the command does.
---@field usage string? How to use the command.
---@field alias string[]? Aliases of the command.
---@field canCall (fun(player: Player): boolean)? Function which checks whether a player can call this command.
---@field call fun(player: Player, human: Human?, args: string[]) Calls the command.
---@field autoComplete fun(args: string[])? Function which manipulates arguments when pressing tab in the terminal.
---@field cooldownTime number? How many seconds a player has to wait before using the command again.
I have also tried with human?: Human and human?: Human? but neither way works.
Reproduction steps
- Create class with a field with a short form function declaration with an optional value parameter
- Attempt to create object of class with that field,
- Parameter correctly types, except as not optional.
Additional Notes
No response
Log File
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず Visual Studio Code extension のクラスフィールドの例を再現し、nullable な Human パラメーターを持つ短縮形式の関数宣言に焦点を当てます。手動で注釈を付けた ---@param man Human? のケースと比較します。パラメーターが optional として推論され、説明どおりに nil チェックの警告が表示されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua, vscode
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100