diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-15 19:00:20 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-15 19:00:20 +0800 |
commit | a86a5884ddbdb32fad8dce1b50c6d0c76c862256 (patch) | |
tree | 33e5592de19171eb61f76e1ef10967a533a149bb /script | |
parent | a93effc7b08c95e1c9f3f852648e09a28e685d05 (diff) | |
download | lua-language-server-a86a5884ddbdb32fad8dce1b50c6d0c76c862256.zip |
resolve #1212
Diffstat (limited to 'script')
-rw-r--r-- | script/vm/compiler.lua | 30 |
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 |