summaryrefslogtreecommitdiff
path: root/server/src/matcher/vm.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-14 19:14:34 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-14 19:14:34 +0800
commitdd1c80a8ef2c05aebe1c3650513fa7f6a360810e (patch)
tree403e765cc1e7983bd2015f90b962b00e84f8f2e4 /server/src/matcher/vm.lua
parent2ded515ba32c01359200d3fe725b0fd062cb1634 (diff)
downloadlua-language-server-dd1c80a8ef2c05aebe1c3650513fa7f6a360810e.zip
暂且先这样
Diffstat (limited to 'server/src/matcher/vm.lua')
-rw-r--r--server/src/matcher/vm.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index b1d303a9..2d1f025a 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -414,12 +414,12 @@ function mt:call(func, values)
if lib then
if lib.args then
for i, arg in ipairs(lib.args) do
- self:inference(self:getFunctionArg(func, i), arg.type)
+ self:inference(self:getFunctionArg(func, i), arg.type or 'any')
end
end
if lib.returns then
for i, rtn in ipairs(lib.returns) do
- self:inference(self:getFunctionReturns(func, i), rtn.type)
+ self:inference(self:getFunctionReturns(func, i), rtn.type or 'any')
end
end
if lib.special then
@@ -461,6 +461,9 @@ function mt:setFunctionReturn(func, index, value)
end
function mt:getFunctionReturns(func, i)
+ if func.maxReturns and i and func.maxReturns < i then
+ return self:createValue('nil')
+ end
if not func.returns then
func.returns = {
type = 'list',
@@ -532,9 +535,18 @@ function mt:getLibValue(lib, parentType, v)
elseif tp == 'function' then
value = self:createValue('function')
if lib.returns then
+ local dots
for i, rtn in ipairs(lib.returns) do
self:setFunctionReturn(value, i, self:getLibValue(rtn, parentType))
+ if rtn.type == '...' then
+ dots = true
+ end
end
+ if not dots then
+ value.maxReturns = #lib.returns
+ end
+ else
+ value.maxReturns = 0
end
if lib.args then
local values = {}