LuaLS / LuaLS/lua-language-server

Error "Undefined field" on _G if global is declared by Lua.diagnostics.globals

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

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

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

Linux

What is the issue affecting?

Diagnostics/Syntax Checking

Expected Behaviour
local extract0 = bit32 and bit32.extract -- Lua 5.2/Lua 5.3 in compatibility mode
local extract = _G.bit32 and _G.bit32.extract -- Lua 5.2/Lua 5.3 in compatibility mode

Expected: No error

Actual Behaviour

Error on 2nd line:

(global) _G.bit32: unknown
Undefined field bit32.Lua Diagnostics.(undefined-field)

Reproduction steps
  1. Add 'bit32' to globals;
  2. Errors on 1st line disappeared; but errors on 2nd line persists.
Additional Notes

sumneko.lua-3.6.18-linux-x64

Real global variables does not trigger errors. Only Lua.diagnostics.globals items lead to errors.

Additional question: how to mute errors for this pattern?

if _G.bit then -- LuaJIT
    local shl, shr, band = _G.bit.lshift, _G.bit.rshift, _G.bit.band
...
end

@diagnostic disable: mute too much, but @diagnostic disable-line: mute too little.

Log File

No response

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

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

はじめの一歩

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

調査の方向性

Lua.diagnostics.globals と bit32 を使用して Visual Studio Code 拡張機能の診断問題を再現し、直接アクセスと _G.bit32 によるアクセスを比較します。設定された globals に対する診断処理を追跡します。_G.bit32 が未定義フィールドを報告しなくなり、無関係な未定義フィールドの診断と行レベルの抑制動作が維持されていれば完了です。

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

評価

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

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

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