From 4399ca74c753c8822a62a2174ab2f47cefe98dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 27 Mar 2023 16:46:50 +0800 Subject: check operator `/`, `^` and `//` fix #2036 --- script/vm/operator.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'script/vm/operator.lua') 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 '..' -- cgit v1.2.3