summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-14 11:28:41 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-14 11:28:41 +0800
commit1b0a19c73d9685cac645f4466ea651376b389f87 (patch)
treef23094d3d91e88033a4f04bc58bab5038683f02c
parent1a0230bba4a1116691a0a2c8ca79d4396f56dfb0 (diff)
downloadlua-language-server-1b0a19c73d9685cac645f4466ea651376b389f87.zip
函数参数有不定参时,准备10个额外参数
-rw-r--r--server/src/matcher/vm.lua3
-rw-r--r--server/test/type_inference/init.lua7
2 files changed, 10 insertions, 0 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua
index 3c1b62af..4a23d759 100644
--- a/server/src/matcher/vm.lua
+++ b/server/src/matcher/vm.lua
@@ -271,6 +271,9 @@ function mt:buildFunction(exp, object)
func.argValues[#func.args] = self:getValue(var)
elseif arg.type == '...' then
self:createDots(#func.args+1, arg)
+ for _ = 1, 10 do
+ func.argValues[#func.argValues+1] = self:createValue('any', arg)
+ end
stop = true
end
end)
diff --git a/server/test/type_inference/init.lua b/server/test/type_inference/init.lua
index d9a23013..bb5add6e 100644
--- a/server/test/type_inference/init.lua
+++ b/server/test/type_inference/init.lua
@@ -165,3 +165,10 @@ local function x(a, ...)
end
x(nil, 'xx', 1, true)
]]
+
+TEST 'number' [[
+local function x(a, ...)
+ return true, 'ss', ...
+end
+local _, _, _, <?b?>, _ = x(nil, true, 1, 'yy')
+]]