summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-08 17:04:32 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-08 17:04:32 +0800
commitb1bd06c0a27426dab6d1e151b116eb7bb53ba03c (patch)
tree29f89c844fd749c3050ed8a8189ffa89c3436368
parentae8ce1e4d975d6aefc947a008ed8a82eec1312d3 (diff)
downloadlua-language-server-b1bd06c0a27426dab6d1e151b116eb7bb53ba03c.zip
async accepts `any`
-rw-r--r--script/core/diagnostics/not-yieldable.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/script/core/diagnostics/not-yieldable.lua b/script/core/diagnostics/not-yieldable.lua
index 0be92e82..612b5b98 100644
--- a/script/core/diagnostics/not-yieldable.lua
+++ b/script/core/diagnostics/not-yieldable.lua
@@ -3,6 +3,7 @@ local await = require 'await'
local guide = require 'parser.guide'
local vm = require 'vm'
local lang = require 'language'
+local infer = require 'core.infer'
local function isYieldAble(defs, i)
local hasFuncDef
@@ -10,15 +11,21 @@ local function isYieldAble(defs, i)
if def.type == 'function' then
hasFuncDef = true
local arg = def.args and def.args[i]
- if arg and vm.isAsync(arg, true) then
- return true
+ if arg then
+ if infer.hasType(arg, 'any')
+ or vm.isAsync(arg, true) then
+ return true
+ end
end
end
if def.type == 'doc.type.function' then
hasFuncDef = true
local arg = def.args and def.args[i]
- if arg and vm.isAsync(arg.extends, true) then
- return true
+ if arg then
+ if infer.hasType(arg.extends, 'any')
+ or vm.isAsync(arg.extends, true) then
+ return true
+ end
end
end
end