From 96946f4022a45519fa4e512c652d322cf8232a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 8 Nov 2021 16:44:04 +0800 Subject: yieldable check linked --- test/diagnostics/init.lua | 59 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua index 96e9e16d..e8e24141 100644 --- a/test/diagnostics/init.lua +++ b/test/diagnostics/init.lua @@ -7,7 +7,6 @@ local catch = require 'catch' config.get 'Lua.diagnostics.neededFileStatus'['deprecated'] = 'Any' config.get 'Lua.diagnostics.neededFileStatus'['type-check'] = 'Any' config.get 'Lua.diagnostics.neededFileStatus'['await-in-sync'] = 'Any' -config.get 'Lua.diagnostics.neededFileStatus'['not-yieldable'] = 'Any' rawset(_G, 'TEST', true) @@ -1419,7 +1418,6 @@ end ]] - TEST [[ ---@nodiscard local function f() @@ -1428,3 +1426,60 @@ end X = f() ]] + +config.get 'Lua.diagnostics.neededFileStatus'['not-yieldable'] = 'Any' +TEST [[ +local function f(cb) + return cb +end + +---@async +local function af() + return nil +end + +f() +]] + +TEST [[ +---@param cb async fun() +local function f(cb) + return cb +end + +---@async +local function af() + return nil +end + +f(af) +]] + +TEST [[ +local function f(cb) + cb() +end + +local function af() + (function () ---@async + return nil + end) +end + +return af +]] + +TEST [[ +local function f(cb) + cb() +end + +---@async +local function af() + f(function () ---@async + return nil + end) +end + +return af +]] -- cgit v1.2.3