LuaLS / LuaLS/lua-language-server

Class definitions get confused with same filenames across folders.

Offen
#3,018 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Lua
Sterne
4.4k
Forks
442
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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?

Diagnostics/Syntax Checking

Expected Behaviour

I have two files, both named the same but in different paths. Each file has its own class and table structure name, which differs from each other.

class A doesn't have method "MyMethod"
class B does
When creating an instance of the class B, and using MyMethod from class B it says that Class A has undefined field "MyMethod" despite being an instance of class B

Renaming class B's file name to something else stops the undefined field warning.

I expect the classes to have differentiation based on the ---@class ClassName syntax, and not the file name.

Actual Behaviour

As you might expect from my description, it does give that warning until the file is renamed.

Reproduction steps
  1. Create a file "test/file.lua" with a class that doesn't implement "MyMethod"
  2. Create a file "file.lua" with a class that does implement "MyMethod"
  3. In your main file, require both, create an instance of both, and try to use MyMethod from instance from step 2
  4. Notice warning about class from step 1 not implementing MyMethod, despite not being used.
Additional Notes

In a small scale test, this didn't seem to happen. But in a full project, the program ran the method LLS says is undefined. Renaming the file and nothing else fixed it so it had something to do with that.

Log File

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere die Warnung mit test/file.lua, file.lua und einer main-Datei, die beide einbindet, wie in den Reproduktionsschritten beschrieben. Beginne mit der Untersuchung der Diagnosen bzw. der Syntaxprüfung rund um die Auflösung von Klassen und Tabellen; fertig ist es, wenn die Instanz aus file.lua gegen ihre eigene Klasse geprüft wird und nicht gegen die gleichnamige Klasse in test/file.lua.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
lua, vscode
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.