summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-01 17:22:42 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-01 17:22:42 +0800
commitab1838ebaab773d37b8e16d3fed0c2c1476aea31 (patch)
treea958fe13b428f285776549e4d5308cb57f5f1c90 /script
parent342ff9af837cdbe0369e717585fcd36638d60002 (diff)
downloadlua-language-server-ab1838ebaab773d37b8e16d3fed0c2c1476aea31.zip
fix #1256
Diffstat (limited to 'script')
-rw-r--r--script/vm/compiler.lua10
-rw-r--r--script/vm/value.lua18
2 files changed, 10 insertions, 18 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index bf0cc44b..1ba20785 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1033,13 +1033,14 @@ local binarySwich = util.switch()
: call(function (source)
local node1 = vm.compileNode(source[1])
local node2 = vm.compileNode(source[2])
- local r1 = vm.testCondition(source[1])
+ local r1 = vm.testCondition(source[1])
if r1 == true then
vm.setNode(source, node2)
elseif r1 == false then
vm.setNode(source, node1)
else
- vm.setNode(source, node2)
+ local node = node1:copy():setFalsy():merge(node2)
+ vm.setNode(source, node)
end
end)
: case 'or'
@@ -1052,9 +1053,8 @@ local binarySwich = util.switch()
elseif r1 == false then
vm.setNode(source, node2)
else
- vm.getNode(source):merge(node1)
- vm.getNode(source):setTruthy()
- vm.getNode(source):merge(node2)
+ local node = node1:copy():setTruthy():merge(node2)
+ vm.setNode(source, node)
end
end)
: case '=='
diff --git a/script/vm/value.lua b/script/vm/value.lua
index 83265603..c4f8e96d 100644
--- a/script/vm/value.lua
+++ b/script/vm/value.lua
@@ -22,24 +22,16 @@ function vm.testCondition(source)
if n[1] == false then
hasFalse = true
end
- end
- if n.type == 'global' and n.cate == 'type' then
- if n.name == 'true' then
- hasTrue = true
- end
+ elseif n.type == 'global' and n.cate == 'type' then
if n.name == 'false'
or n.name == 'nil' then
hasFalse = true
+ else
+ hasTrue = true
end
- end
- if n.type == 'nil' then
+ elseif n.type == 'nil' then
hasFalse = true
- end
- if n.type == 'string'
- or n.type == 'number'
- or n.type == 'integer'
- or n.type == 'table'
- or n.type == 'function' then
+ elseif guide.isLiteral(n) then
hasTrue = true
end
end