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 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://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/files.lua:879>
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 摘要。