LuaLS / LuaLS/lua-language-server
False negative for param-type-mismatch when using a variable as argument
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?
Type Checking
### Expected Behaviour
```lua
---@class (exact) Foo
---@field FooField integer
local Foo
---@param FooParam Foo
local function test(FooParam) end
local x = {z = 1}
test(x)
test({z = 1})
```
In the example above, Lua LS should report a param-type-mismatch diagnostic for `test(x)`. It has enough information to know that x cannot be of type Foo, at the very least because it is missing `FooField`.
We see that test({z=1}) correctly reports the param-type-mismatch diagnostic.
### Actual Behaviour
No error is reported.

### Reproduction steps
In any editor with Lua LS installed, write the provided code. Observe that there are no squiggles reported.
### Additional Notes
I would say this is a pretty serious bug. I would have expected Lua LS's type checking to be robust enough to handle checking the types of variables. It seems that all it is doing is checking that the type is a table.
IS this because there is no narrowing of variables once they become tables? This is only done for table literals?
### 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
Inizia con la riproduzione Lua fornita in Lua LS e segui il percorso del controllo dei tipi per il parametro passato a test, confrontando l'argomento variabile con il literal di tabella. Il lavoro è completato quando viene riportata la stessa diagnostica param-type-mismatch per test(x), incluso il caso di FooField mancante.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- lua
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100