From 05b8cf4e0f92798c08aceb74891de5fb025ae1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 17 Jun 2022 15:51:03 +0800 Subject: fix #1223 count returns of `doc.type.function` --- script/core/diagnostics/missing-parameter.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'script') 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 -- cgit v1.2.3