LuaLS / LuaLS/lua-language-server
Hover preview incorrectly narrows union of literal and type
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?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Linux
What is the issue affecting?
Hover
Expected Behaviour
---@alias inttype -1 | 0 | integer
---@type inttype
local intvar = 1
---@alias stringtype "a" | "b" | string
---@type stringtype
local stringvar = "x"
I expect the hover previews for inttype, intvar, stringtype, and stringvar to show the full expansion of the intttype and stringtype aliases, something like
inttype:
| -1
| 0
| integer
and
stringtype:
| "a"
| "b"
| string
Actual Behaviour
The rendered preview of the type aliases omits the overall type:
inttype:
| -1
| 0
and
stringtype:
| "a"
| "b"
This is especially weird because if those were the actual type definitions then the two assignments in the example would be type errors, which they are not.
Reproduction steps
Put the code above into a Lua file in vscode with the language server extension running. Hover over the type aliases and the variables. The problem happens with just one literal in each union, two aren't required but I thought they illustrated the preview problem better.
Additional Notes
The reason I want to make "useless" union types like this is for hinting to humans that those specific values are special in some way.
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
Reproduza o problema em um arquivo Lua aberto na extensão do Visual Studio Code passando o cursor sobre os aliases e as variáveis mostrados no relatório. Rastreie o caminho de renderização de tipos do hover para unions que combinam valores literais com integer ou string e verifique se as prévias mantêm o tipo geral junto com os membros literais.
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
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100