LuaLS / LuaLS/lua-language-server
Class definitions get confused with same filenames across folders.
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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
- Create a file "test/file.lua" with a class that doesn't implement "MyMethod"
- Create a file "file.lua" with a class that does implement "MyMethod"
- In your main file, require both, create an instance of both, and try to use MyMethod from instance from step 2
- 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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
再現手順で説明されているとおり、test/file.lua、file.lua、および両方を require する main ファイルを使って警告を再現します。まず、クラスとテーブルの解決に関する diagnostics/syntax checking を調べます。完了条件は、file.lua のインスタンスが test/file.lua にある同名のクラスではなく、自身のクラスに対してチェックされることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua, vscode
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100