summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-07 09:49:25 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-07 09:49:25 +0800
commita55bc60e412ac97ca90d4dc4f13c15f58b0a6cdb (patch)
treeca7adfa03e6e30e47bf4d5ef5c58ed17508c97ad /server/src
parent2718985dff1312d47cc80077e9d2068a33ca9f6e (diff)
downloadlua-language-server-a55bc60e412ac97ca90d4dc4f13c15f58b0a6cdb.zip
修正除0的bug
Diffstat (limited to 'server/src')
-rw-r--r--server/src/core/vm.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua
index b490ccf9..36a8f21b 100644
--- a/server/src/core/vm.lua
+++ b/server/src/core/vm.lua
@@ -1118,13 +1118,19 @@ function mt:getBinary(exp)
elseif op == '*' then
return self:createValue('number', nil, v1.value * v2.value)
elseif op == '/' then
- return self:createValue('number', nil, v1.value / v2.value)
+ if v2.value ~= 0 then
+ return self:createValue('number', nil, v1.value / v2.value)
+ end
elseif op == '^' then
return self:createValue('number', nil, v1.value ^ v2.value)
elseif op == '%' then
- return self:createValue('number', nil, v1.value % v2.value)
+ if v2.value ~= 0 then
+ return self:createValue('number', nil, v1.value % v2.value)
+ end
elseif op == '//' then
- return self:createValue('number', nil, v1.value // v2.value)
+ if v2.value ~= 0 then
+ return self:createValue('number', nil, v1.value // v2.value)
+ end
end
end
return self:createValue('number')