summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-15 19:00:20 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-15 19:00:20 +0800
commita86a5884ddbdb32fad8dce1b50c6d0c76c862256 (patch)
tree33e5592de19171eb61f76e1ef10967a533a149bb /script
parenta93effc7b08c95e1c9f3f852648e09a28e685d05 (diff)
downloadlua-language-server-a86a5884ddbdb32fad8dce1b50c6d0c76c862256.zip
resolve #1212
Diffstat (limited to 'script')
-rw-r--r--script/vm/compiler.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 0cbe2b7a..acb39432 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1786,6 +1786,36 @@ local compilerSwitch = util.switch()
return
end
end
+ if source.op.type == '>'
+ or source.op.type == '<'
+ or source.op.type == '>='
+ or source.op.type == '<=' then
+ local a = vm.getNumber(source[1])
+ local b = vm.getNumber(source[2])
+ if a and b then
+ local result
+ if source.op.type == '>' then
+ result = a > b
+ elseif source.op.type == '<' then
+ result = a < b
+ elseif source.op.type == '>=' then
+ result = a >= b
+ elseif source.op.type == '<=' then
+ result = a <= b
+ end
+ vm.setNode(source, {
+ type = 'boolean',
+ start = source.start,
+ finish = source.finish,
+ parent = source,
+ [1] = result,
+ })
+ return
+ else
+ vm.setNode(source, vm.declareGlobal('type', 'boolean'))
+ return
+ end
+ end
end)
---@param source vm.object