lua-language-server
lua-language-server copied to clipboard
Missing "need-check-nil" on self fields
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