diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-08-17 14:48:14 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-08-17 14:48:14 +0800 |
commit | 210a400e2c6f222ce0ad6c038a2e03cea117c877 (patch) | |
tree | 0a6a825412e7207c16d2f666434a8db26361211a /script-beta/parser/guide.lua | |
parent | 85f2cf816e5b3e2d439731e48129678a32b70d60 (diff) | |
download | lua-language-server-210a400e2c6f222ce0ad6c038a2e03cea117c877.zip |
过测试
Diffstat (limited to 'script-beta/parser/guide.lua')
-rw-r--r-- | script-beta/parser/guide.lua | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 835e62ba..a6d5be3b 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -2122,8 +2122,10 @@ function m.inferCheckUnary(status, source) end local function mathCheck(status, a, b) - local v1 = m.getInferLiteral(status, a, 'integer') or m.getInferLiteral(status, a, 'number') - local v2 = m.getInferLiteral(status, b, 'integer') or m.getInferLiteral(status, a, 'number') + local v1 = m.getInferLiteral(status, a, 'integer') + or m.getInferLiteral(status, a, 'number') + local v2 = m.getInferLiteral(status, b, 'integer') + or m.getInferLiteral(status, a, 'number') local int = m.hasType(status, a, 'integer') and m.hasType(status, b, 'integer') and not m.hasType(status, a, 'number') @@ -2207,8 +2209,10 @@ function m.inferCheckBinary(status, source) } return true elseif op.type == '<=' then - local v1 = m.getInferLiteral(status, source[1], 'integer') or m.getInferLiteral(status, source[1], 'number') - local v2 = m.getInferLiteral(status, source[2], 'integer') or m.getInferLiteral(source[2], 'number') + local v1 = m.getInferLiteral(status, source[1], 'integer') + or m.getInferLiteral(status, source[1], 'number') + local v2 = m.getInferLiteral(status, source[2], 'integer') + or m.getInferLiteral(source[2], 'number') local v if v1 and v2 then v = v1 <= v2 @@ -2220,8 +2224,10 @@ function m.inferCheckBinary(status, source) } return true elseif op.type == '>=' then - local v1 = m.getInferLiteral(status, source[1], 'integer') or m.getInferLiteral(status, source[1], 'number') - local v2 = m.getInferLiteral(status, source[2], 'integer') or m.getInferLiteral(status, source[2], 'number') + local v1 = m.getInferLiteral(status, source[1], 'integer') + or m.getInferLiteral(status, source[1], 'number') + local v2 = m.getInferLiteral(status, source[2], 'integer') + or m.getInferLiteral(status, source[2], 'number') local v if v1 and v2 then v = v1 >= v2 @@ -2233,8 +2239,10 @@ function m.inferCheckBinary(status, source) } return true elseif op.type == '<' then - local v1 = m.getInferLiteral(status, source[1], 'integer') or m.getInferLiteral(status, source[1], 'number') - local v2 = m.getInferLiteral(status, source[2], 'integer') or m.getInferLiteral(status, source[2], 'number') + local v1 = m.getInferLiteral(status, source[1], 'integer') + or m.getInferLiteral(status, source[1], 'number') + local v2 = m.getInferLiteral(status, source[2], 'integer') + or m.getInferLiteral(status, source[2], 'number') local v if v1 and v2 then v = v1 < v2 @@ -2246,8 +2254,10 @@ function m.inferCheckBinary(status, source) } return true elseif op.type == '>' then - local v1 = m.getInferLiteral(status, source[1], 'integer') or m.getInferLiteral(status, source[1], 'number') - local v2 = m.getInferLiteral(source[2], 'integer') or m.getInferLiteral(status, source[2], 'number') + local v1 = m.getInferLiteral(status, source[1], 'integer') + or m.getInferLiteral(status, source[1], 'number') + local v2 = m.getInferLiteral(source[2], 'integer') + or m.getInferLiteral(status, source[2], 'number') local v if v1 and v2 then v = v1 > v2 @@ -2337,8 +2347,10 @@ function m.inferCheckBinary(status, source) } return true elseif op.type == '^' then - local v1 = m.getInferLiteral(status, source[1], 'integer') or m.getInferLiteral(status, source[1], 'number') - local v2 = m.getInferLiteral(source[2], 'integer') or m.getInferLiteral(status, source[2], 'number') + local v1 = m.getInferLiteral(status, source[1], 'integer') + or m.getInferLiteral(status, source[1], 'number') + local v2 = m.getInferLiteral(source[2], 'integer') + or m.getInferLiteral(status, source[2], 'number') local v if v1 and v2 then v = v1 ^ v2 @@ -2350,8 +2362,10 @@ function m.inferCheckBinary(status, source) } return true elseif op.type == '/' then - local v1 = m.getInferLiteral(status, source[1], 'integer') or m.getInferLiteral(status, source[1], 'number') - local v2 = m.getInferLiteral(status, source[2], 'integer') or m.getInferLiteral(status, source[2], 'number') + local v1 = m.getInferLiteral(status, source[1], 'integer') + or m.getInferLiteral(status, source[1], 'number') + local v2 = m.getInferLiteral(status, source[2], 'integer') + or m.getInferLiteral(status, source[2], 'number') local v if v1 and v2 then v = v1 > v2 @@ -2515,7 +2529,7 @@ function m.inferByDef(status, obj) if status.index > 1 then return end - local newStatus = m.status(status) + local newStatus = m.status(nil, status.interface) m.searchRefs(newStatus, obj, 'def') for _, src in ipairs(newStatus.results) do local inferStatus = m.status(status) @@ -2691,7 +2705,7 @@ function m.inferByCallReturn(status, source) return end local node = source.vararg.node - local newStatus = m.status(status) + local newStatus = m.status(nil, status.interface) m.searchRefs(newStatus, node, 'def') local index = source.index for _, src in ipairs(newStatus.results) do @@ -2721,7 +2735,7 @@ function m.inferByPCallReturn(status, source) else return end - local newStatus = m.status(status) + local newStatus = m.status(nil, status.interface) m.searchRefs(newStatus, func, 'def') for _, src in ipairs(newStatus.results) do if src.value and src.value.type == 'function' then |