LuaLS / LuaLS/lua-language-server
Missing "need-check-nil" on self fields
未關閉
還沒有人認領這個 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?
Type Checking, Diagnostics/Syntax Checking
Expected Behaviour
I expect both methods to report the "need check nil" diagnostic:
---@class Y
---@field z string
---@class X
---@field y Y?
local X = {}
function X:no_warning()
print(self.y.z) -- no diagnostics
end
function X:warning()
local y = self.y
print(y.z) -- need-check-nil
end
Actual Behaviour
The potential problem is only reported when using a local variable.
Reproduction steps
Try the code above. and note how only the first method (no_warning) works without any diagnostics.
Additional Notes
No response
Log File
No response
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
使用報告中的 Lua 程式碼片段在 Visual Studio Code 擴充功能中重現問題,並比較 self.y.z 與區域變數案例 y.z 的診斷結果。追蹤負責 nil 檢查的型別檢查或診斷進入點;完成標準是兩個方法都回報 need-check-nil 診斷,且不變更範例中的型別。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- lua
- 領域
- devtools
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 52/100