summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/diagnostics/not-yieldable.lua4
-rw-r--r--test/diagnostics/init.lua10
2 files changed, 12 insertions, 2 deletions
diff --git a/script/core/diagnostics/not-yieldable.lua b/script/core/diagnostics/not-yieldable.lua
index 465f6a8b..5736b1e2 100644
--- a/script/core/diagnostics/not-yieldable.lua
+++ b/script/core/diagnostics/not-yieldable.lua
@@ -9,9 +9,9 @@ local function isYieldAble(defs, i)
local hasFuncDef
for _, def in ipairs(defs) do
if def.type == 'function' then
- hasFuncDef = true
local arg = def.args and def.args[i]
if arg then
+ hasFuncDef = true
if infer.hasType(arg, 'any')
or vm.isAsync(arg, true)
or arg.type == '...' then
@@ -20,9 +20,9 @@ local function isYieldAble(defs, i)
end
end
if def.type == 'doc.type.function' then
- hasFuncDef = true
local arg = def.args and def.args[i]
if arg then
+ hasFuncDef = true
if infer.hasType(arg.extends, 'any')
or vm.isAsync(arg.extends, true) then
return true
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index cfe29d04..58414b60 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -1461,6 +1461,16 @@ end)
]]
TEST [[
+local function f(...)
+ return ...
+end
+
+f(1, function () ---@async
+ return nil
+end)
+]]
+
+TEST [[
---@nodiscard
local function f()
return 1