LuaLS / LuaLS/lua-language-server
Bug with incorrectly reporting undefined-global
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Lua
- Star
- 4.4k
- Fork
- 442
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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')
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện sự cố trong repository WeakAuras bằng extension VSCode và các cài đặt workspace đã được báo cáo. Bắt đầu từ script/core/diagnostics/param-type-mismatch.lua ở dòng 21 và theo dõi stack qua script/provider/diagnostic.lua; hoàn thành khi việc lập chỉ mục chẩn đoán không còn gây crash và các báo cáo về global chưa được định nghĩa vẫn chính xác sau khi lập chỉ mục lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- lua
- Lĩnh vực
- devtools
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100