diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-03-13 17:50:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-03-13 17:50:49 +0800 |
commit | 671d9526cbfa83c01e74aa3405f1d32b647822d7 (patch) | |
tree | 09721d61fb0f297a574b0fbda668d245764dab14 /script/vm | |
parent | a2cc1076556bde7ed91036926c5007e4ac66b0d2 (diff) | |
download | lua-language-server-671d9526cbfa83c01e74aa3405f1d32b647822d7.zip |
infer unknown operation as unknown
#1996
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/operator.lua | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/script/vm/operator.lua b/script/vm/operator.lua index b2a3aa10..48e29304 100644 --- a/script/vm/operator.lua +++ b/script/vm/operator.lua @@ -249,7 +249,9 @@ vm.binarySwitch = util.switch() }) else local node = vm.runOperator(binaryMap[op], source[1], source[2]) - vm.setNode(source, node or vm.declareGlobal('type', 'integer')) + if node then + vm.setNode(source, node) + end end end) : case '+' @@ -296,20 +298,17 @@ vm.binarySwitch = util.switch() local uri = guide.getUri(source) local infer1 = vm.getInfer(source[1]) local infer2 = vm.getInfer(source[2]) - if infer1:hasType(uri, 'integer') - or infer2:hasType(uri, 'integer') then - if not infer1:hasType(uri, 'number') - and not infer2:hasType(uri, 'number') then - vm.setNode(source, vm.declareGlobal('type', 'integer')) - return - end + if infer1:hasType(uri, 'integer') + and infer2:hasType(uri, 'integer') then + vm.setNode(source, vm.declareGlobal('type', 'integer')) + return + end + if (infer1:hasType(uri, 'number') or infer1:hasType(uri, 'integer')) + and (infer2:hasType(uri, 'number') or infer2:hasType(uri, 'integer')) then + vm.setNode(source, vm.declareGlobal('type', 'number')) + return end end - if op == '//' then - vm.setNode(source, node or vm.declareGlobal('type', 'integer')) - return - end - vm.setNode(source, node or vm.declareGlobal('type', 'number')) end end) : case '..' @@ -346,7 +345,9 @@ vm.binarySwitch = util.switch() }) else local node = vm.runOperator(binaryMap[source.op.type], source[1], source[2]) - vm.setNode(source, node or vm.declareGlobal('type', 'string')) + if node then + vm.setNode(source, node) + end end end) : case '>' |