summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/vm/value.lua3
-rw-r--r--test/type_inference/init.lua9
2 files changed, 12 insertions, 0 deletions
diff --git a/script/vm/value.lua b/script/vm/value.lua
index 92f1a2b9..83265603 100644
--- a/script/vm/value.lua
+++ b/script/vm/value.lua
@@ -9,6 +9,9 @@ function vm.testCondition(source)
return nil
end
local node = vm.compileNode(source)
+ if node.optional then
+ return nil
+ end
local hasTrue, hasFalse
for n in node:eachObject() do
if n.type == 'boolean'
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 61677cea..a05749b8 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -3209,3 +3209,12 @@ local n
print(<?n?>)
]]
+
+TEST 'integer' [[
+---@type integer?
+local n
+if true then
+ n = 0
+end
+local <?x?> = n or 0
+]]