summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-02-14 15:08:39 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-02-14 15:08:39 +0800
commitcaec2f97984f72d0ecb5f0c35174c682e749ac8a (patch)
tree1a24e8f6d61011773cf661cc49413991ee8b22de
parenta8a3b6fd320b226d1b1779a337dd69502da1f666 (diff)
downloadlua-language-server-caec2f97984f72d0ecb5f0c35174c682e749ac8a.zip
库函数支持检查参数数量
-rw-r--r--server/src/core/diagnostics.lua3
-rw-r--r--server/src/core/vm.lua4
-rw-r--r--server/test/diagnostics/init.lua12
3 files changed, 16 insertions, 3 deletions
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua
index 3cfe4d55..f6bf3aa4 100644
--- a/server/src/core/diagnostics.lua
+++ b/server/src/core/diagnostics.lua
@@ -195,9 +195,6 @@ end
function mt:searchRedundantParameters(callback)
local results = self.results
for _, call in ipairs(results.calls) do
- if not call.func.built then
- goto NEXT_CALL
- end
if call.func.hasDots then
goto NEXT_CALL
end
diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua
index 79381876..812c3945 100644
--- a/server/src/core/vm.lua
+++ b/server/src/core/vm.lua
@@ -836,9 +836,13 @@ function mt:getLibValue(lib, parentType, v)
value.maxReturns = 0
end
if lib.args then
+ value.args = lib.args
local values = {}
for i, arg in ipairs(lib.args) do
values[i] = self:getLibValue(arg, parentType) or self:createValue('any')
+ if arg.type == '...' then
+ value.hasDots = true
+ end
end
self:setFunctionArg(value, values)
end
diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua
index 8a2dcf61..0227680c 100644
--- a/server/test/diagnostics/init.lua
+++ b/server/test/diagnostics/init.lua
@@ -156,3 +156,15 @@ local function f(<!self!>)
end
f()
]]
+
+TEST [[
+local function f(a, b)
+ return a, b
+end
+f(1, 2, <!3!>)
+]]
+
+TEST [[
+next({}, 1, <!2!>)
+print(1, 2, 3, 4, 5)
+]]