LuaLS / LuaLS/lua-language-server

Global in one file affects diagnostics in another

オープン
#2,340 コメント 5 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
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

If I have 1.lua:

function Main()
    foobar = 1
end

and 2.lua:

function Main()
    print(foobar)
end

in the same workspace/directory.

I would expect 2.lua to show foobar as undefined (unless I explicitly require 1.lua)

Actual Behaviour

No error is shown.

Additional Notes

This might be a pecularity of how I'm using lua (each file defines a separate plugin) but I would be surprised if this is an uncommon usage pattern. At the very least there should be a way to configure the behaviour.

Also - I'd be curious to understand the thinking behind the existing behaviour?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

同じ workspace 内で 1.lua と 2.lua を使って Visual Studio Code extension の例を再現し、その後、language server がファイル間でグローバル変数をどのように共有しているかを追跡します。明示的な require の使用が診断にどのような影響を与えるべきか、また設定オプションが必要かどうかを判断します。1.lua が明示的に require されていない限り、2.lua が foobar を未定義として報告すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
lua, vscode
領域
devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。