LuaLS / LuaLS/lua-language-server
False negative for param-type-mismatch when using a variable as argument
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Lua
- Estrellas
- 4.4k
- Forks
- 442
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
### 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_
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la reproducción de Lua proporcionada en Lua LS y sigue la ruta de comprobación de tipos para el parámetro pasado a test, comparando el argumento variable con el literal de tabla. Se considera terminado cuando se informa el mismo diagnóstico param-type-mismatch para test(x), incluido el caso de FooField ausente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- lua
- Área
- devtools
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 42/100