LuaLS / LuaLS/lua-language-server

Bug with incorrectly reporting undefined-global

未關閉
#1,702 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

Info Needed
主要語言
Lua
星號
4.4k
分支
442
PR 合併指標
30 天內沒有已合併 PR

描述

So I have this very strange bug where the VSCode extension starts reporting undefined-globals but when I click on the actual problem report, it goes away.

These globals are defined in a file that is loaded as a library via an [extension](https://github.com/Ketho/vscode-wow-api) so I figured I might reach the max workspace files/size limit but even with those set to very high numbers it keeps happening. I can click on all of them to make them go away but the next indexing run (hitting save) will bring them back.

`workspace.maxPreload` is set to `20000`
`workspace.preloadFileSize` is set to `8000`

The repo I tested with is [WeakAuras](https://github.com/WeakAuras/WeakAuras2)

https://user-images.githubusercontent.com/75278/202040021-d15fda8e-85ce-4055-a39e-d9538f6b5446.mp4

So my next guess was that the LSP just crashes and restarts, I checked the output panel and got this:

```
script/core/diagnostics/param-type-mismatch.lua:21: attempt to index a nil value (field 'generic')
stack traceback:
script/core/diagnostics/param-type-mismatch.lua:21: in upvalue 'expandGenerics'
script/core/diagnostics/param-type-mismatch.lua:48: in upvalue 'getDefNode'
script/core/diagnostics/param-type-mismatch.lua:97: in local 'callback'
script/parser/guide.lua:716: in function 'parser.guide.eachSourceType'
script/core/diagnostics/param-type-mismatch.lua:83: in function 'core.diagnostics.param-type-mismatch'
script/core/diagnostics/init.lua:117: in upvalue 'check'
script/core/diagnostics/init.lua:174: in function 'core.diagnostics'
[C]: in function 'xpcall'
script/provider/diagnostic.lua:324: in function 'provider.diagnostic.doDiagnostic'
[C]: in function 'xpcall'
script/provider/diagnostic.lua:665: in upvalue 'callback'
script/files.lua:880: in function
script/core/diagnostics/param-type-mismatch.lua:21: attempt to index a nil value (field 'generic')
```

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

使用 VSCode 擴充功能和回報的工作區設定,在 WeakAuras 儲存庫中重現此問題。從 script/core/diagnostics/param-type-mismatch.lua 的第 21 行開始,沿著經過 script/provider/diagnostic.lua 的呼叫堆疊追蹤;當診斷索引不再當機,且重新索引後未定義全域變數的報告仍然正確時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
lua
領域
devtools
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。