Skip to content

Commit 2dfed8a

Browse files
committed
fix
1 parent e5e7c27 commit 2dfed8a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

script/core/diagnostics/missing-return.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ return function (uri, callback)
6363
return
6464
end
6565
await.delay()
66-
if vm.countReturnsOfFunction(source) == 0 then
66+
if vm.countReturnsOfFunction(source, true) == 0 then
6767
return
6868
end
6969
if hasReturn(source) then

script/vm/function.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ function vm.countParamsOfNode(node)
8080
end
8181

8282
---@param func parser.object
83+
---@param onlyDoc? boolean
8384
---@param mark? table
8485
---@return integer min
8586
---@return number max
86-
function vm.countReturnsOfFunction(func, mark)
87+
function vm.countReturnsOfFunction(func, onlyDoc, mark)
8788
if func.type == 'function' then
8889
---@type integer?
8990
local min
@@ -123,7 +124,7 @@ function vm.countReturnsOfFunction(func, mark)
123124
max = dmax
124125
end
125126
end
126-
if not hasDocReturn and func.returns then
127+
if not onlyDoc and not hasDocReturn and func.returns then
127128
for _, ret in ipairs(func.returns) do
128129
local rmin, rmax = vm.countList(ret, mark)
129130
if not min or rmin < min then
@@ -153,7 +154,7 @@ function vm.countReturnsOfCall(func, args, mark)
153154
---@type number?
154155
local max
155156
for _, f in ipairs(funcs) do
156-
local rmin, rmax = vm.countReturnsOfFunction(f, mark)
157+
local rmin, rmax = vm.countReturnsOfFunction(f, false, mark)
157158
if not min or rmin < min then
158159
min = rmin
159160
end

0 commit comments

Comments
 (0)