LuaLS / LuaLS/lua-language-server
Hover preview incorrectly narrows union of literal and type
Personne n'a encore pris cette issue.
- Langage dominant
- Lua
- Étoiles
- 4.4k
- Forks
- 442
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
### 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
```lua
---@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_
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Reproduisez le problème dans un fichier Lua ouvert dans l’extension Visual Studio Code en survolant les alias et les variables affichés dans le rapport. Suivez le chemin de rendu des types au survol pour les unions combinant des valeurs littérales avec integer ou string, et vérifiez que les aperçus conservent le type global avec les membres littéraux.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- lua
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100