LuaLS / LuaLS/lua-language-server

Ability to use specific enum keys as params

Aperta
#2,274 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

It would be nice to be able to use specific enum keys as params. For example today if you try to do something like this:

```
---@enum TestEnum
TestEnum = {
ONE = 1,
TWO = 2,
THREE = 3,
}

---@param test TestEnum.ONE
local function test(test)
end

test(TestEnum.ONE)
test(1)
```

You will get an error:
```
Cannot assign `integer` to parameter `TestEnum.ONE`.
- `integer` cannot match `TestEnum.ONE`
- Type `integer` cannot match `TestEnum.ONE`
- Type `number` cannot match `TestEnum.ONE`
```

Interestingly lls understands that TestEnum.ONE is a real thing just not that it is equal to TestEnum.ONE or 1. For exmaple if you try this:
```
---@enum TestEnum
TestEnum = {
ONE = 1,
TWO = 2,
THREE = 3,
}

---@param test TestEnum.One
local function test(test)
end

test(TestEnum.ONE)
test(1)
```
You will get an error:
```
---@param test TestEnum.NonEnumValue
```

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

Poiché nell’issue non sono identificati file, test o punti di ingresso, inizia individuando il controllo dei tipi enum e la gestione dell’assegnabilità dei parametri in lua-language-server. Il lavoro è completato quando TestEnum.ONE viene accettato per TestEnum.ONE e il suo valore sottostante 1 viene gestito in modo coerente, mentre le chiavi enum non valide continuano a essere rifiutate.

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

Valutazione

Stack tecnologico
lua
Ambito
devtools
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
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.