LuaLS / LuaLS/lua-language-server
Missing diagnostic when calling a non-function value
Nessuno ha ancora preso questa issue.
- Lingua principale
- Lua
- Stelle
- 4.4k
- Fork
- 442
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci il problema con gli snippet Lua che chiamano valori numerici e stringa, quindi traccia il punto di ingresso della diagnostica o del controllo dei tipi che gestisce le espressioni di chiamata. Il lavoro è completato quando vengono segnalate diagnosi per i valori sicuramente non chiamabili, mentre le tabelle chiamabili e i valori con firme esplicite di overload o __call continuano a essere accettati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- lua
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 65/100