summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-07 15:10:19 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-07 15:10:19 +0800
commit0b87804cba3f24318362993ca2e32e0f95ce990d (patch)
tree18eb9d21b8b824255a18fedbbf9a6bcd9452c78f /script
parentca299b0289c0f79972d83c44baa29cde20ce31f4 (diff)
downloadlua-language-server-0b87804cba3f24318362993ca2e32e0f95ce990d.zip
#1294 fix operator `and`/`or` for boolean
Diffstat (limited to 'script')
-rw-r--r--script/vm/node.lua4
-rw-r--r--script/vm/value.lua2
2 files changed, 3 insertions, 3 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua
index fdd9a2c0..d84b7030 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -188,8 +188,8 @@ function mt:setFalsy()
if c.type == 'nil'
or (c.type == 'global' and c.cate == 'type' and c.name == 'nil')
or (c.type == 'global' and c.cate == 'type' and c.name == 'false')
- or (c.type == 'boolean' and c[1] == true)
- or (c.type == 'doc.type.boolean' and c[1] == true) then
+ or (c.type == 'boolean' and c[1] == false)
+ or (c.type == 'doc.type.boolean' and c[1] == false) then
goto CONTINUE
end
if (c.type == 'global' and c.cate == 'type' and c.name == 'boolean')
diff --git a/script/vm/value.lua b/script/vm/value.lua
index c4f8e96d..23a9f2c9 100644
--- a/script/vm/value.lua
+++ b/script/vm/value.lua
@@ -26,7 +26,7 @@ function vm.testCondition(source)
if n.name == 'false'
or n.name == 'nil' then
hasFalse = true
- else
+ elseif n.name ~= 'boolean' then
hasTrue = true
end
elseif n.type == 'nil' then