LuaLS / LuaLS/lua-language-server
string|nil passed to string parameter not flagged as error with strict settings
オープン
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
How are you using the lua-language-server?
Command Line
Which OS are you using?
Linux
What is the issue affecting?
Type Checking
Expected Behaviour
With the following config (see below), I expect Lua Language Server to report a type mismatch when passing a string|nil value to a function that expects a non-optional string parameter.
Specifically, this line should raise a diagnostic:
test_func(params.ip) -- where params.ip is string|nil, but test_func expects string
Actual Behaviour
No error is reported by LLS, neither in VS Code nor when using the CLI with --check.
Reproduction steps
- Save this code in a
.luafile:
---@class TestParams
---@field ip string | nil
---@param ip string
---@return string
local function test_func(ip)
return ip
end
---@type TestParams
local params = { ip = nil }
test_func(params.ip)
- Use the following
lua-language-server config(.luarc.jsonor through your client):
{
"runtime": {
"version": "Lua 5.1"
},
"diagnostics": {
"enable": true,
"disable": [],
"groupFileStatus": {
"ambiguity": "Any",
"await": "Any",
"codestyle": "Any",
"duplicate": "Any",
"global": "Any",
"luadoc": "Any",
"redefined": "Any",
"strict": "Any",
"strong": "Any",
"type-check": "Any",
"unbalanced": "Any",
"unused": "Any"
},
"groupSeverity": {
"ambiguity": "Error",
"await": "Error",
"codestyle": "Error",
"duplicate": "Error",
"global": "Error",
"luadoc": "Error",
"redefined": "Error",
"strict": "Error",
"strong": "Error",
"type-check": "Error",
"unbalanced": "Error",
"unused": "Error"
}
},
"type": {
"weakNilCheck": false
}
}
- Run the CLI:
lua-language-server-3.15.0-linux-x64/bin/lua-language-server --check your_file.lua
Or use VS Code extension.
Additional Notes
No response
Log File
Diagnosis completed, no problems found
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された Lua の再現コードと .luarc.json から始め、続いて文書化されている lua-language-server --check コマンドを実行して、診断が欠落していることを確認します。関数引数の型チェックの経路を追跡し、回帰テストを追加します。完了の条件は、引数 string|nil が必須の string パラメーターと互換性がないと報告されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100