LuaLS / LuaLS/lua-language-server
Hover preview incorrectly narrows union of literal and type
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Lua
- Sterne
- 4.4k
- Forks
- 442
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere das Problem in einer Lua-Datei, die in der Visual Studio Code-Erweiterung geöffnet ist, indem du mit dem Mauszeiger über die im Bericht gezeigten Aliase und Variablen fährst. Verfolge den Pfad für die Darstellung von Typen beim Hover für Unions, die Literalwerte mit integer oder string kombinieren, und überprüfe, dass die Vorschauen neben den Literal-Mitgliedern auch den Gesamttyp beibehalten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- lua
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100