diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-10-20 20:49:11 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-10-20 20:49:11 +0800 |
commit | 0c7a22d1106cd97b47cb969e2ccfd86ca7ae2629 (patch) | |
tree | 28be218460604922063a2ca9af44f270e77e1c78 /script/vm | |
parent | 1c79bbc9d1a238e4cc900c506690e52f8e5f12f2 (diff) | |
download | lua-language-server-0c7a22d1106cd97b47cb969e2ccfd86ca7ae2629.zip |
ignore varargs
if a function only has varargs and has `---@overload`, the varargs will be ignored
resolve #1641
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/doc.lua | 7 | ||||
-rw-r--r-- | script/vm/function.lua | 25 |
2 files changed, 31 insertions, 1 deletions
diff --git a/script/vm/doc.lua b/script/vm/doc.lua index 293cf5c3..b292bc3c 100644 --- a/script/vm/doc.lua +++ b/script/vm/doc.lua @@ -112,6 +112,13 @@ local function getDeprecated(value) end end end + if value.type == 'function' then + local doc = getDeprecated(value.parent) + if doc then + value._deprecated = doc + return doc + end + end value._deprecated = false return nil end diff --git a/script/vm/function.lua b/script/vm/function.lua index 7cde6298..8b996721 100644 --- a/script/vm/function.lua +++ b/script/vm/function.lua @@ -218,7 +218,7 @@ function vm.getMatchedFunctions(func, args, mark) local funcs = {} local node = vm.compileNode(func) for n in node:eachObject() do - if n.type == 'function' + if (n.type == 'function' and not vm.isVarargFunctionWithOverloads(n)) or n.type == 'doc.type.function' then funcs[#funcs+1] = n end @@ -243,3 +243,26 @@ function vm.getMatchedFunctions(func, args, mark) return matched end end + +---@param func table +---@return boolean +function vm.isVarargFunctionWithOverloads(func) + if func.type ~= 'function' then + return false + end + if not func.args then + return false + end + if func.args[1].type ~= '...' then + return false + end + if not func.bindDocs then + return false + end + for _, doc in ipairs(func.bindDocs) do + if doc.type == 'doc.overload' then + return true + end + end + return false +end |