Missing diagnostic when calling a non-function value
まだ誰も着手していません。
評価
調査の方向性
数値および文字列の値を呼び出す Lua スニペットで問題を再現し、その後、呼び出し式を処理する診断または型チェックのエントリーポイントを追跡します。明らかに呼び出し不可能な値について診断が報告される一方で、呼び出し可能なテーブルと明示的なオーバーロードまたは __call シグネチャを持つ値は引き続き受け入れられれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
LuaLS should report a diagnostic when a value whose type is known to be non-callable is called like a function.
For example, calling a number, string, boolean, or a plain table without a known __call / @overload signature should produce a warning/error, because the code will fail at runtime.
Actual Behaviour
No diagnostic is reported.
Even when the value is explicitly annotated or cast as number, LuaLS accepts the call silently.
Reproduction steps
Use the following code:
local x = 1 --[[@as number]]
x()
local y = 1
y()
---@type number
local z = 1
z()
Expected: diagnostics on x(), y(), and z().
Actual: no diagnostics are reported.
At runtime, these calls fail with an error similar to:
attempt to call a number value
Additional Notes
This is different from callable table / __call support.
I am not asking LuaLS to reject values that are explicitly annotated as callable, for example with ---@overload fun(...) or an equivalent __call signature.
The issue is about direct calls to values whose inferred or declared type is definitely not callable, such as number.
This also affects typo detection. For example, code like this can accidentally parse as a function call:
---@param name string
local function greet(name)
return "Hello " .. name "!"
end
Here name "!" is a call expression, but name is a string, so a diagnostic would be useful.
Log File
No response
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- 平均マージ
- 8日 9時間
- マージ済み PR(30日)
- 1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
LuaLS/lua-language-server のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
LuaLS/lua-language-server#1776 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
LuaLS/lua-language-server#3463 · コメント 5 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
LuaLS/lua-language-server#3461 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
LuaLS/lua-language-server#3460 · コメント 1 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
LuaLS/lua-language-server#3459 · リアクション 1 件 ·
LuaLS/lua-language-server の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
LandSandBoat/server#11579 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ArchiveTeam/sinavideo-grab#7 · リアクション 3 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
mailcow/mailcow-dockerized#7480 ·
-
mapper bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100