diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 17:31:51 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-21 17:31:51 +0800 |
commit | fdbc2738d8a79aaf76ba2177b9144295886e39b8 (patch) | |
tree | aea8dd596a348ce168e52a5247d7d48965bf58e1 /server | |
parent | 1376bba0f9cfc3e8f06130c3bb4f86589b0dc32a (diff) | |
download | lua-language-server-fdbc2738d8a79aaf76ba2177b9144295886e39b8.zip |
修正多返回值遇到函数调用的bug
Diffstat (limited to 'server')
-rw-r--r-- | server/src/matcher/vm.lua | 12 | ||||
-rw-r--r-- | server/test/definition/bug.lua | 6 |
2 files changed, 15 insertions, 3 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index 413b9291..6248e550 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -991,11 +991,17 @@ function mt:doReturn(action) for i, exp in ipairs(action) do local value = self:getExp(exp) if value.type == 'list' then - for x, v in ipairs(value) do + if i == #action then + for x, v in ipairs(value) do + self:addInfo(v, 'return', exp) + self:setFunctionReturn(self:getCurrentFunction(), i + x - 1, v) + end + break + else + local v = value[1] or self:createValue('nil', exp) self:addInfo(v, 'return', exp) - self:setFunctionReturn(self:getCurrentFunction(), i + x - 1, v) + self:setFunctionReturn(self:getCurrentFunction(), i, v) end - break else self:addInfo(value, 'return', exp) self:setFunctionReturn(self:getCurrentFunction(), i, value) diff --git a/server/test/definition/bug.lua b/server/test/definition/bug.lua index 05420b7c..b5e8dbe9 100644 --- a/server/test/definition/bug.lua +++ b/server/test/definition/bug.lua @@ -77,3 +77,9 @@ local t = { <?x?>, } ]] + +TEST [[ +local a +local <!b!> +return f(), <?b?> +]] |