summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-29 21:07:41 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-29 21:07:41 +0800
commitfe121d00514898842a07b67a257a1af2cb2fb604 (patch)
tree71e38c17149ea1e8fe6b2b1c9e4c32c6b1df3626
parente7b0b8a3c66e096d361aa49be1b953aa7eb0506d (diff)
downloadlua-language-server-fe121d00514898842a07b67a257a1af2cb2fb604.zip
fix #1103
-rw-r--r--changelog.md1
-rw-r--r--script/core/diagnostics/missing-parameter.lua1
-rw-r--r--script/core/diagnostics/redundant-parameter.lua4
-rw-r--r--test/diagnostics/common.lua6
4 files changed, 11 insertions, 1 deletions
diff --git a/changelog.md b/changelog.md
index 70c469e1..c6b5f29e 100644
--- a/changelog.md
+++ b/changelog.md
@@ -4,6 +4,7 @@
* `CHG` parse `.luarc.json` as jsonc. In order to please the editor, it also supports `.luarc.jsonc` as the file name.
* `CHG` dose not load files in symbol links
* `FIX` diagnostic: send empty results to every file after startup
+* `FIX` [#1103](https://github.com/sumneko/lua-language-server/issues/1103)
## 3.2.2
`2022-4-26`
diff --git a/script/core/diagnostics/missing-parameter.lua b/script/core/diagnostics/missing-parameter.lua
index 88e7b87e..698680ca 100644
--- a/script/core/diagnostics/missing-parameter.lua
+++ b/script/core/diagnostics/missing-parameter.lua
@@ -21,6 +21,7 @@ local function countFuncArgs(source)
for i = #source.args, 1, -1 do
local arg = source.args[i]
if arg.type ~= '...'
+ and not (arg.name and arg.name[1] =='...')
and not vm.compileNode(arg):isNullable() then
return i
end
diff --git a/script/core/diagnostics/redundant-parameter.lua b/script/core/diagnostics/redundant-parameter.lua
index 2f921f3a..41781df8 100644
--- a/script/core/diagnostics/redundant-parameter.lua
+++ b/script/core/diagnostics/redundant-parameter.lua
@@ -16,7 +16,9 @@ local function countFuncArgs(source)
if not source.args or #source.args == 0 then
return 0
end
- if source.args[#source.args].type == '...' then
+ local lastArg = source.args[#source.args]
+ if lastArg.type == '...'
+ or (lastArg.name and lastArg.name[1] == '...') then
return math.maxinteger
else
return #source.args
diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua
index 17f20ee2..56d1cbcc 100644
--- a/test/diagnostics/common.lua
+++ b/test/diagnostics/common.lua
@@ -218,6 +218,12 @@ x(1, 2, 3, 4, 5)
]]
TEST [[
+---@type fun(a, b, ...)
+local x
+x(1, 2, 3, 4, 5)
+]]
+
+TEST [[
local m = {}
function m:x(a, b)
return a, b