LuaLS / LuaLS/lua-language-server

Hover preview incorrectly narrows union of literal and type

Aperta
#2,885 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Lua
Stelle
4.4k
Fork
442
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il problema in un file Lua aperto nell’estensione Visual Studio Code passando con il cursore sugli alias e sulle variabili mostrati nel report. Segui il percorso di rendering dei tipi al passaggio del mouse per le union che combinano valori letterali con integer o string e verifica che le anteprime mantengano il tipo complessivo insieme ai membri letterali.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
lua
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.