LuaLS / LuaLS/lua-language-server
Enum type is lost when given as union
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 WSL
What is the issue affecting?
Type Checking
Expected Behaviour
A parameter of union of enum entries should accept those entries.
Actual Behaviour
---Command constants.
---
---@enum CMD
CMD = {
---@type 40
REPAIR = nil,
---@type 90
RECLAIM = nil,
---@type 110
RESTORE = nil,
---@type 125
RESURRECT = nil,
---@type 130
CAPTURE = nil,
}
---Called when a construction unit wants to "use his nano beams".
---
---@param unitID integer
---@param unitDefID integer
---@param action
--- | -1 # Build
--- | CMD.REPAIR # Repair
--- | CMD.RECLAIM # Reclaim
--- | CMD.RESTORE # Restore
--- | CMD.RESURRECT # Resurrect
--- | CMD.CAPTURE # Capture
---@return boolean actionAllowed
function SyncedCallins:AllowBuilderHoldFire(unitID, unitDefID, action) end
local x = nil ---@type SyncedCallins
local y = x:AllowBuilderHoldFire(5, 3, CMD.REPAIR)
The enum type is being resolved to 40 and losing information about it being an enum.
[{
"resource": "/home/rhys/spring/rts/Lua/library/generated/library.lua",
"owner": "_generated_diagnostic_collection_name_#1",
"code": "param-type-mismatch",
"severity": 4,
"message": "Cannot assign `40` to parameter `-1|CMD.CAPTURE|CMD.RECLAIM|CMD.REPAIR|CMD.RESTORE...(+1)`.\n- `40` cannot match `-1|CMD.CAPTURE|CMD.RECLAIM|CMD.REPAIR|CMD.RESTORE...(+1)`\n- `40` cannot match any subtypes in `-1|CMD.CAPTURE|CMD.RECLAIM|CMD.REPAIR|CMD.RESTORE...(+1)`\n- Type `40` cannot match `CMD.CAPTURE`\n- Type `number` cannot match `CMD.CAPTURE`\n- Type `40` cannot match `CMD.RESURRECT`\n- Type `number` cannot match `CMD.RESURRECT`\n- Type `40` cannot match `CMD.RESTORE`\n- Type `number` cannot match `CMD.RESTORE`\n- Type `40` cannot match `CMD.RECLAIM`\n- Type `number` cannot match `CMD.RECLAIM`\n- Type `40` cannot match `CMD.REPAIR`\n- Type `number` cannot match `CMD.REPAIR`\n- Literal `40` cannot match integer `-1`",
"source": "Lua Diagnostics.",
"startLineNumber": 3090,
"startColumn": 40,
"endLineNumber": 3090,
"endColumn": 50
}]
Reproduction steps
Paste code example above into VSCode.
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
Reproduzca el diagnóstico en Visual Studio Code utilizando el ejemplo de Lua del issue y, a continuación, inspeccione la ruta de comprobación de tipos indicada para generated/library.lua. El cambio estará completo cuando CMD.REPAIR y los demás miembros del enum se acepten como argumentos de la unión documentada sin un diagnóstico param-type-mismatch.
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
- 45/100