LuaLS / LuaLS/lua-language-server
Lua Language Server Fails to Infer Type When Passing Multiple Return Values to Generic Function
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?
NeoVim
Which OS are you using?
MacOS
What is the issue affecting?
Type Checking
Expected Behaviour
---@return integer
---@return string
local f = function()
return 1, "a"
end
---@generic T
---@generic U
---@param t T
---@param u U
---@return U
local g = function(t, u)
return u
end
local x = g(f())
When the function g is called with the multiple return values of f, the Lua Language Server should infer the type of x based on the second return value of f (string), corresponding to the second generic type parameter (U) in g.
Actual Behaviour
The Lua Language Server fails to infer the type of x. Instead, the type is left unknown.
Reproduction steps
- Write the following Lua code in an editor with the Lua Language Server enabled:
---@return integer
---@return string
local f = function()
return 1, "a"
end
---@generic T
---@generic U
---@param t T
---@param u U
---@return U
local g = function(t, u)
return u
end
local x = g(f())
- Observe the type inference for x.
- Note that the type of x is not inferred as string as expected.
Additional Notes
No response
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 riproducendo lo snippet Lua in NeoVim con Lua Language Server abilitato e ispeziona il percorso di inferenza dei tipi generici per le chiamate che ricevono più valori di ritorno. Il lavoro è completato quando la variabile x viene inferita come string, in corrispondenza del secondo valore di ritorno di f e del parametro generico U.
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
- 38/100