diff options
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/diagnostics/missing-parameter.lua | 19 | ||||
-rw-r--r-- | test/diagnostics/common.lua | 12 |
3 files changed, 28 insertions, 4 deletions
diff --git a/changelog.md b/changelog.md index 436370c9..1803c901 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ * `FIX` [#1217](https://github.com/sumneko/lua-language-server/issues/1217) * `FIX` [#1218](https://github.com/sumneko/lua-language-server/issues/1218) * `FIX` [#1220](https://github.com/sumneko/lua-language-server/issues/1220) +* `FIX` [#1223](https://github.com/sumneko/lua-language-server/issues/1223) ## 3.3.0 `2022-6-15` diff --git a/script/core/diagnostics/missing-parameter.lua b/script/core/diagnostics/missing-parameter.lua index a475673f..9844046f 100644 --- a/script/core/diagnostics/missing-parameter.lua +++ b/script/core/diagnostics/missing-parameter.lua @@ -5,7 +5,7 @@ local lang = require 'language' ---@param source parser.object ---@return integer -local function countReturns(source) +local function countReturnsOfFunction(source) local n = 0 local docs = source.bindDocs @@ -33,14 +33,25 @@ local function countReturns(source) return n end +---@param source parser.object +---@return integer +local function countReturnsOfDocFunction(source) + return #source.returns +end + local function countMaxReturns(source) local hasFounded local n = 0 for _, def in ipairs(vm.getDefs(source)) do - if def.type == 'doc.type.function' - or def.type == 'function' then + if def.type == 'function' then + hasFounded = true + local rets = countReturnsOfFunction(def) + if rets > n then + n = rets + end + elseif def.type == 'doc.type.function' then hasFounded = true - local rets = countReturns(def) + local rets = countReturnsOfDocFunction(def) if rets > n then n = rets end diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua index 428d8a45..53186198 100644 --- a/test/diagnostics/common.lua +++ b/test/diagnostics/common.lua @@ -1601,3 +1601,15 @@ end f1(f2()) ]] + +TEST [[ +---@meta + +---@type fun():integer +local f + +---@param x integer +local function foo(x) end + +foo(f()) +]] |