diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/vm.lua | 21 | ||||
-rw-r--r-- | server/test/type_inference/init.lua | 5 |
2 files changed, 11 insertions, 15 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index df722501..36634710 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -553,7 +553,7 @@ function mt:getLibValue(lib, parentType, v) elseif tp == 'nil' then value = self:createValue('nil') else - value = self:createValue(tp) + value = self:createValue(tp or 'any') end self.libraryValue[lib] = value value.lib = lib @@ -610,7 +610,9 @@ function mt:unpackDots(res, expect) end function mt:unpackList(list, expect) - local res = {} + local res = { + type = 'list', + } if list.type == 'list' or list.type == 'call' then for i, exp in ipairs(list) do if exp.type == '...' then @@ -948,21 +950,10 @@ function mt:doLoop(action) end function mt:doIn(action) - local func - local list = { - type = 'list' - } - if action.exp.type == 'list' then - func = self:getExp(action.exp[1]) - for i = 2, #action.exp do - list[i-1] = action.exp[i] - end - else - func = self:getExp(action.exp) - end + local args = self:unpackList(action.exp) self.scope:push() - local args = self:unpackList(list) + local func = table.remove(args, 1) or self:createValue('any') local values = self:call(func, args) self:forList(action.arg, function (arg) local value = table.remove(values, 1) diff --git a/server/test/type_inference/init.lua b/server/test/type_inference/init.lua index bb5add6e..820d00c9 100644 --- a/server/test/type_inference/init.lua +++ b/server/test/type_inference/init.lua @@ -172,3 +172,8 @@ local function x(a, ...) end local _, _, _, <?b?>, _ = x(nil, true, 1, 'yy') ]] + +TEST 'integer' [[ +for <?i?> in ipairs(t) do +end +]] |