diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-07 09:49:25 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-07 09:49:25 +0800 |
commit | a55bc60e412ac97ca90d4dc4f13c15f58b0a6cdb (patch) | |
tree | ca7adfa03e6e30e47bf4d5ef5c58ed17508c97ad /server/src | |
parent | 2718985dff1312d47cc80077e9d2068a33ca9f6e (diff) | |
download | lua-language-server-a55bc60e412ac97ca90d4dc4f13c15f58b0a6cdb.zip |
修正除0的bug
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/core/vm.lua | 12 |
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') |