Skip to content

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

@4lph4-Ph4un

Description

@4lph4-Ph4un

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions