LuaLS / LuaLS/lua-language-server
---@class with function return question
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
so I have this (as a mockup):
do
---@class a
local a = {}
---@generic T
---@param self a
---@param new T
---@return T
a.extend = function(self, new)
--...
return new
end
end
and it's supposed to be inheritance for prototypes, right, but I'm trying to make the LS think that it returns the second parameter new and it does that and the LS thinks that, so far so good. So this
local b = a:extend{
n = 1
}
will make it like this:
but the problem is, that if I use ---@class b here, then it will ignore what the function returns and I get this:
am I missing something or is it just not possible? Though, if I separate it into two statements like this,
---@class b
local b = {
n = 1
}
b = a:extend(b)
then I get what I want:
but it's not ideal, since it's two statements now and I can't use the fun{} syntactic sugar this way, which would be the whole reason, right. Is there a way to make it work? Also I'm unsure about how to properly word the title here
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
Non vengono indicati file sorgente né test. Riproduci i due snippet Lua su una riga e i due a due istruzioni, quindi traccia l’inferenza dei tipi di LuaLS per le dichiarazioni locali, le annotazioni delle classi, i generics e i valori restituiti dalle funzioni. Il lavoro è completato quando il comportamento supportato è implementato e coperto da un test di regressione, oppure quando la limitazione è documentata chiaramente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- lua
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100