LuaLS / LuaLS/lua-language-server

Global in one file affects diagnostics in another

未關閉
#2,340 5 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
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. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 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 摘要。