LuaLS / LuaLS/lua-language-server
lua-language-server not detecting types when destructuring Tuple types with ~table.unpack~
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Lua
- Estrelas
- 4.4k
- Forks
- 442
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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
- Define tuple like I did
- Create such tuple
unpackto 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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece reproduzindo o problema com o exemplo de tuple e table.unpack do relatório e, em seguida, acompanhe a inferência de tipos do language server para multiple assignment e unpacked tables. Nenhum arquivo-fonte ou teste é nomeado; considera-se concluído quando o exemplo infere c como integer e d como boolean sem causar regressões nos diagnósticos existentes de tuple.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- lua
- Domínio
- tooling
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100