From 2dfed8a4aabd66c98777d37245ef5482b5ffdd48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sun, 3 Jul 2022 15:34:36 +0800 Subject: fix --- script/core/diagnostics/missing-return.lua | 2 +- script/vm/function.lua | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'script') diff --git a/script/core/diagnostics/missing-return.lua b/script/core/diagnostics/missing-return.lua index 435e8a96..e3539ac0 100644 --- a/script/core/diagnostics/missing-return.lua +++ b/script/core/diagnostics/missing-return.lua @@ -63,7 +63,7 @@ return function (uri, callback) return end await.delay() - if vm.countReturnsOfFunction(source) == 0 then + if vm.countReturnsOfFunction(source, true) == 0 then return end if hasReturn(source) then diff --git a/script/vm/function.lua b/script/vm/function.lua index 5723fbc6..0e04408c 100644 --- a/script/vm/function.lua +++ b/script/vm/function.lua @@ -80,10 +80,11 @@ function vm.countParamsOfNode(node) end ---@param func parser.object +---@param onlyDoc? boolean ---@param mark? table ---@return integer min ---@return number max -function vm.countReturnsOfFunction(func, mark) +function vm.countReturnsOfFunction(func, onlyDoc, mark) if func.type == 'function' then ---@type integer? local min @@ -123,7 +124,7 @@ function vm.countReturnsOfFunction(func, mark) max = dmax end end - if not hasDocReturn and func.returns then + if not onlyDoc and not hasDocReturn and func.returns then for _, ret in ipairs(func.returns) do local rmin, rmax = vm.countList(ret, mark) if not min or rmin < min then @@ -153,7 +154,7 @@ function vm.countReturnsOfCall(func, args, mark) ---@type number? local max for _, f in ipairs(funcs) do - local rmin, rmax = vm.countReturnsOfFunction(f, mark) + local rmin, rmax = vm.countReturnsOfFunction(f, false, mark) if not min or rmin < min then min = rmin end -- cgit v1.2.3