summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/diagnostics/missing-return.lua2
-rw-r--r--script/vm/function.lua7
2 files changed, 5 insertions, 4 deletions
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