Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

@field private in @meta file triggers warning even when accessed within the same class

Aperta
#3,211 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
lua
Ambito
devtools

Direzione di ricerca

Riproduci l’avviso usando gli esempi types.lua e ModuleMixin.lua, iniziando dalla diagnostica dei campi privati nel language server. Traccia come vengono associati la dichiarazione della classe e il relativo file di implementazione. Il lavoro è completo quando gli accessi dall’implementazione non generano più avvisi, mentre i controlli sui campi privati rimangono intatti altrove.

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

Descrizione

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Annotations

Expected Behaviour

When defining a class in a ---@meta file with @field private annotations, the Lua language server warns about accessing those private fields even when they are accessed within the implementation of the same class (just in a separate file). This makes private fields effectively unusable if you're organizing types in meta files.

The language server should not warn about access to @field private fields when they are accessed within the implementation of the class they belong to, even if that implementation is in a separate file.

I think this is by design rather than a bug, so maybe this is a feature request?

Actual Behaviour

Even though I'm accessing the private field in the implementation of that class, I see a warning:

Image

Reproduction steps
  1. In types.lua (meta file)
---@meta

---@class (exact) ModuleMixin
---@field private __loaded boolean
---@field Load fun(self)
---@field IsLoaded fun(self): boolean
---@field Init fun(self)
  1. ModuleMixin.lua (implementation)
---@type SmartChat.ModuleMixin
local ModuleMixin = {}

function ModuleMixin:Init()
  self.__loaded = false  -- <-- LuaLS warns that __loaded is private
end
Additional Notes

I use a @meta file to separate type annotations from implementation, which is common in larger projects. This issue makes it difficult to use private meaningfully unless everything is co-located in the same file, which defeats the purpose of a metadata/type declaration file.

Would it be possible to make private refer to "the class definition context" rather than "the file only"?

Thanks!

Log File

No response

Lingua principale
Lua
Stelle
4.4k
Fork
442
Merge medio
8g 9h
PR unite (30g)
1

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.

Altre issue di LuaLS/lua-language-server

Tutte le issue di LuaLS/lua-language-server

Issue simili

Altre issue su Lua

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.