LuaLS / LuaLS/lua-language-server
Missing diagnostic when calling a non-function value
まだ誰も着手していません。
- 主要言語
- 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
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:
```lua
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:
```lua
---@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_
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
数値および文字列の値を呼び出す Lua スニペットで問題を再現し、その後、呼び出し式を処理する診断または型チェックのエントリーポイントを追跡します。明らかに呼び出し不可能な値について診断が報告される一方で、呼び出し可能なテーブルと明示的なオーバーロードまたは __call シグネチャを持つ値は引き続き受け入れられれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 65/100