lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

lua-language-server not detecting types when destructuring Tuple types with ~table.unpack~

Open 4lph4-Ph4un opened this issue 1 year ago • 1 comments

How are you using the lua-language-server?

Other

Which OS are you using?

Windows

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour

I might be wrong here, but I assume this should work? Language server should detect the types from the defined tuple:

---@alias my_tuple { [1]: integer, [2]: boolean }

---@type my_tuple
local tuple = {1, true}

--- This works!
local a, b = tuple[1], tuple[2]

--- This gets "integer" for "c", but "unknown" for "d:
local c, d = table.unpack(tuple)

Actual Behaviour

---@alias my_tuple { [1]: integer, [2]: boolean }

---@type my_tuple
local tuple = {1, true}

---  "c" should be "integer" and "d" "boolean":
local c, d = table.unpack(tuple)

Reproduction steps

  1. Define tuple like I did
  2. Create such tuple
  3. unpack to two variables

Additional Notes

I'm not sure if this is a feature that is even considered, but since I do use unpack sometimes to destructure tuples into their distinct variables, I feel this would be a good feature to have.

Log File

No response

4lph4-Ph4un avatar Sep 27 '24 19:09 4lph4-Ph4un