LuaLS / LuaLS/lua-language-server
Support for a bottom type for non-returning functions
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
Have a way to tag the return type of a function as Bottom, i.e., never returns.
Actual Behaviour
I have a snippet like this:
local function abort(err)
io.stderr:write(err .. "\n")
os.exit(1)
end
local function stuff()
local chunk = loadfile("x.lua")
if not chunk then
abort("failed to loadfile()")
end
chunk()
return {}
end
stuff()
which triggers the "need-nil-check" diagnostic on "chunk()" because it doesn't understand that abort() never returns, so i would like to tag abort() (or better tag os.exit() and do return os.exit) as never returning function.
obvious work-around is to do "return abort(...)" instead, but that messes up the return type of stuff() from table to table|nil. so i have to write abort() return {} to make the type checker happy which is a bit cumbersome
Reproduction steps
- Go to '...'
- Click '...'
- See error '...'
Additional Notes
No response
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 ruta de comprobación de tipos para el diagnóstico need-nil-check y las anotaciones existentes de tipo de retorno de las funciones. Compara el tratamiento solicitado de abort y os.exit con la forma en que el checker infiere stuff() después de la llamada. Se considera terminado cuando una función que no retorna puede representarse de modo que se evite el diagnóstico de nil sin añadir nil al tipo de retorno de stuff().
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- lua
- Área
- devtools
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100