summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-23 23:24:23 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-23 23:24:23 +0800
commit3f815c836beb054a13f8d250f6f05a54778b72ba (patch)
tree04e39933feecbc34cd8ef36c86f838ea8181c635 /script/vm
parenta7afda10d2ea044a8ea3c83d4656736a6969a101 (diff)
downloadlua-language-server-3f815c836beb054a13f8d250f6f05a54778b72ba.zip
new diagnostic: `need-check-nil`
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/compiler.lua3
-rw-r--r--script/vm/node.lua2
-rw-r--r--script/vm/sign.lua2
3 files changed, 3 insertions, 4 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 4917d33a..1f33a784 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1435,9 +1435,8 @@ local compilerSwitch = util.switch()
elseif r1 == false then
vm.setNode(source, node1)
else
- vm.getNode(source):merge(node1)
- vm.getNode(source):setTruly()
vm.getNode(source):merge(node2)
+ vm.getNode(source):addOptional()
end
end
if source.op.type == 'or' then
diff --git a/script/vm/node.lua b/script/vm/node.lua
index d52c2a84..06023ca5 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -80,7 +80,7 @@ function mt:isOptional()
end
---@return boolean
-function mt:isFalsy()
+function mt:hasFalsy()
if self.optional then
return true
end
diff --git a/script/vm/sign.lua b/script/vm/sign.lua
index 78d61022..795916fa 100644
--- a/script/vm/sign.lua
+++ b/script/vm/sign.lua
@@ -128,7 +128,7 @@ function mt:resolve(uri, args, removeGeneric)
local function buildArgNode(argNode, knownTypes)
local newArgNode = vm.createNode()
for n in argNode:eachObject() do
- if argNode:isFalsy() then
+ if argNode:hasFalsy() then
goto CONTINUE
end
local view = infer.viewObject(n)