LuaLS / LuaLS/lua-language-server
A union type should not merge class fields
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?
MacOS
### What is the issue affecting?
Annotations
### Expected Behaviour
```lua
---@class (exact) TypeA
---@field type 'A'
---@field commonField number
---@field specificFieldA number
---@class (exact) TypeB
---@field type 'B'
---@field commonField string
---@field specificFieldB string
---@alias Type_Either_A_Or_B_But_Not_Both TypeA|TypeB
---@type Type_Either_A_Or_B_But_Not_Both
local testA = {
type = 'A', --- Indicates that this should be of TypeA
commonField = 'test', --- Should be an error. TypeA.commonField should be a number
specificFieldA = 123, --- OK
specificFieldB = 'Hello' --- Should be an error. TypeA.specificFieldB doesn't exist
}
---@type Type_Either_A_Or_B_But_Not_Both
local testB = {
type = 'B', --- Indicates that this should be of TypeB
commonField = 'test', --- OK
specificFieldA = 123, --- Should be an error. TypeB.specificFieldA doesn't exist
specificFieldB = 'Hello' --- OK
}
```
### Actual Behaviour
`TypeA|TypeB` is merged, so none of the mismatched fields/types are reported as errors.
```
local testA: TypeA|TypeB {
commonField: string|number,
specificFieldA: number,
specificFieldB: string,
type: 'A'|'B',
}
```
### Reproduction steps
Paste the code into vscode
### Additional Notes
_No response_
### Log File
_No response_
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci l'esempio annotato TypeA|TypeB nell'estensione Visual Studio Code, quindi traccia il modo in cui il language server unisce i campi delle classi union. Il lavoro è completato quando il discriminatore seleziona la classe corretta e segnala il campo comune non corrispondente commonField e i campi specifici dei membri mostrati nell'esempio.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- lua
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100