diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-27 10:08:30 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-27 10:08:30 +0800 |
commit | c396fb4527a5684b75672654f28208255954edcf (patch) | |
tree | bfea757388f78c9977522bac820fef3b8935ee05 /server/src | |
parent | 87af08f8a72cc285421d8df19501c6529541f958 (diff) | |
download | lua-language-server-c396fb4527a5684b75672654f28208255954edcf.zip |
值得类型不能是...
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/matcher/vm.lua | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index f054f800..dfa0d0d9 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -664,12 +664,20 @@ 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 or 'any') + if arg.type == '...' then + self:inference(self:getFunctionArg(func, i), 'any') + else + self:inference(self:getFunctionArg(func, i), arg.type or 'any') + end end end if lib.returns then for i, rtn in ipairs(lib.returns) do - self:inference(self:getFunctionReturns(func, i), rtn.type or 'any') + if rtn.type == '...' then + self:inference(self:getFunctionReturns(func, i), 'any') + else + self:inference(self:getFunctionReturns(func, i), rtn.type or 'any') + end end end if lib.special then @@ -750,12 +758,19 @@ function mt:getFunctionReturns(func, i) end function mt:inference(value, type) + if type == '...' then + error('Value type cant be ...') + end if value.type == 'any' and type ~= 'nil' then value.type = type end end function mt:createValue(tp, source, v) + if tp == '...' then + error('Value type cant be ...') + end + -- TODO lib里的多类型 if type(tp) == 'table' then tp = tp[1] end @@ -834,6 +849,8 @@ function mt:getLibValue(lib, parentType, v) value = self:createValue('integer', nil, v or lib.value) elseif tp == 'nil' then value = self:createValue('nil') + elseif tp == '...' then + value = self:createValue('any') else value = self:createValue(tp or 'any') end |