diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-03-27 16:46:50 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-03-27 16:46:59 +0800 |
commit | 4399ca74c753c8822a62a2174ab2f47cefe98dca (patch) | |
tree | 7256a41378b56426b456a7800271c8591733ccb4 /script | |
parent | 114695a4db97d9a1fe88a29fd2905f4ccb06ce45 (diff) | |
download | lua-language-server-4399ca74c753c8822a62a2174ab2f47cefe98dca.zip |
check operator `/`, `^` and `//`
fix #2036
Diffstat (limited to 'script')
-rw-r--r-- | script/vm/operator.lua | 21 |
1 files changed, 21 insertions, 0 deletions
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 '..' |