diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-03-29 14:38:30 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-03-29 14:38:30 +0800 |
commit | 7fdff5fcd4625a238ab48a23a066c3e013d3ec0b (patch) | |
tree | ff346a2c486635106ba8b6bb082ba7948939b20a /script/vm/operator.lua | |
parent | 3a761da3d574639aac1f7ef06b1976bf3f255ad3 (diff) | |
download | lua-language-server-7fdff5fcd4625a238ab48a23a066c3e013d3ec0b.zip |
fix #2037
Diffstat (limited to 'script/vm/operator.lua')
-rw-r--r-- | script/vm/operator.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/script/vm/operator.lua b/script/vm/operator.lua index 5c63387a..bc8703c6 100644 --- a/script/vm/operator.lua +++ b/script/vm/operator.lua @@ -372,6 +372,22 @@ vm.binarySwitch = util.switch() [1] = a .. b, }) else + 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') + or infer1:hasType(uri, 'string') + ) + and ( + infer2:hasType(uri, 'integer') + or infer2:hasType(uri, 'number') + or infer2:hasType(uri, 'string') + ) then + vm.setNode(source, vm.declareGlobal('type', 'string')) + return + end local node = vm.runOperator(binaryMap[source.op.type], source[1], source[2]) if node then vm.setNode(source, node) |