diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-29 21:07:41 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-29 21:07:41 +0800 |
commit | fe121d00514898842a07b67a257a1af2cb2fb604 (patch) | |
tree | 71e38c17149ea1e8fe6b2b1c9e4c32c6b1df3626 | |
parent | e7b0b8a3c66e096d361aa49be1b953aa7eb0506d (diff) | |
download | lua-language-server-fe121d00514898842a07b67a257a1af2cb2fb604.zip |
fix #1103
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/diagnostics/missing-parameter.lua | 1 | ||||
-rw-r--r-- | script/core/diagnostics/redundant-parameter.lua | 4 | ||||
-rw-r--r-- | test/diagnostics/common.lua | 6 |
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 |