You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lua Language Server Fails to Infer Type When Passing Multiple Return Values to Generic Function #3007
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:
I have a similar problem. In my case, when I wrap the return values in a table that I'm passing to a function it says that I am passing it only a table filled on the first index.
However, when I save it to a variable first, it still thinks there is only the first index, but for some reason passes the variable to the function with no error.
functionmr() return1,2,3,4endlocalx= {mr} -- still infers {[1]=number}-- says values [2],[3],[4] are missingvim.treesitter.get_parser(0):node_for_range({mr()})
-- doesn't say anything and correctly infers the called function's return typevim.treesitter.get_parser(0):node_for_range(x)
This ends up being very inconvenient, because even with the diagnostic ignored it still believes there is no match for the parameters therefore the return type of function that received the table is unknown. And that breaks the type inference and completion for everything using that and so on.
Activity
litoj commentedon Nov 6, 2025
I have a similar problem. In my case, when I wrap the return values in a table that I'm passing to a function it says that I am passing it only a table filled on the first index.
However, when I save it to a variable first, it still thinks there is only the first index, but for some reason passes the variable to the function with no error.
This ends up being very inconvenient, because even with the diagnostic ignored it still believes there is no match for the parameters therefore the return type of function that received the table is unknown. And that breaks the type inference and completion for everything using that and so on.