-
-
Notifications
You must be signed in to change notification settings - Fork 371
Open
Labels
enhancementNew feature or requestNew feature or requestfeat/type checkRelated to the type checking featureRelated to the type checking feature
Milestone
Description
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
Expected Behaviour
After cheking for null in IF block, variable should return not null.
Actual Behaviour
After cheking for null in IF block, variable returns nullable value, so it causes warning
solution: check in two if blocks or use --[[@as not_nullable_type]]
Reproduction steps
---@Class Mclass
local var1= {
---@type number?
var2 = nil,
}
---@param number
local function fun1(var2) end
if var1 and var1.var2 then
local var2= var1.var2
fun1(var2) --Cannot assign number?
to parameter number
.
end
Additional Notes
No response
Log File
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestfeat/type checkRelated to the type checking featureRelated to the type checking feature