summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md5
-rw-r--r--script/vm/operator.lua21
-rw-r--r--test/type_inference/init.lua7
3 files changed, 33 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index 84815b7c..4bad6917 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,10 @@
# changelog
+## 3.6.19
+* `FIX` [#2036]
+
+[#2036]: https://github.com/LuaLS/lua-language-server/issues/2036
+
## 3.6.18
`2023-3-23`
* `FIX` [#1943]
diff --git a/script/vm/operator.lua b/script/vm/operator.lua
index 9c68e648..5c63387a 100644
--- a/script/vm/operator.lua
+++ b/script/vm/operator.lua
@@ -316,6 +316,27 @@ vm.binarySwitch = util.switch()
return
end
end
+ if op == '/'
+ or op == '^' then
+ local uri = guide.getUri(source)
+ local infer1 = vm.getInfer(source[1])
+ local infer2 = vm.getInfer(source[2])
+ if (infer1:hasType(uri, 'integer') or infer1:hasType(uri, 'number'))
+ and (infer2:hasType(uri, 'integer') or infer2:hasType(uri, 'number')) then
+ vm.setNode(source, vm.declareGlobal('type', 'number'))
+ return
+ end
+ end
+ if op == '//' then
+ local uri = guide.getUri(source)
+ local infer1 = vm.getInfer(source[1])
+ local infer2 = vm.getInfer(source[2])
+ if (infer1:hasType(uri, 'integer') or infer1:hasType(uri, 'number'))
+ and (infer2:hasType(uri, 'integer') or infer2:hasType(uri, 'number')) then
+ vm.setNode(source, vm.declareGlobal('type', 'integer'))
+ return
+ end
+ end
end
end)
: case '..'
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index bc70fbf4..13585790 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -4254,3 +4254,10 @@ local fooOrBar
local <?b?> = foo * fooOrBar
]]
+
+TEST 'number' [[
+local a = 4;
+local b = 2;
+
+local <?c?> = a / b;
+]]