summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-11-08 23:33:15 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-11-08 23:33:15 +0800
commit4d73939b6ec2320f72b35e1e193b8bf1fb18f64c (patch)
treeccd6e90f7ed456b80ea32cfbac562aee475897ba /test
parente7f8bc78843c03c677668a676f124902b2b889a2 (diff)
downloadlua-language-server-4d73939b6ec2320f72b35e1e193b8bf1fb18f64c.zip
fix incorrect type check for generic with nil
Diffstat (limited to 'test')
-rw-r--r--test/diagnostics/type-check.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index 434cf5bc..ff2eddea 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -1088,6 +1088,32 @@ end
func('hello', 'world')
]]
+TEST [[
+---@generic T1, T2, T3, T4, T5
+---@param f fun(): T1?, T2?, T3?, T4?, T5?
+---@return T1?, T2?, T3?, T4?, T5?
+local function foo(f)
+ return f()
+end
+
+local a, b = foo(function()
+ return 1
+end)
+]]
+
+TEST [[
+---@generic T1, T2, T3, T4, T5
+---@param f fun(): T1|nil, T2|nil, T3|nil, T4|nil, T5|nil
+---@return T1?, T2?, T3?, T4?, T5?
+local function foo(f)
+ return f()
+end
+
+local a, b = foo(function()
+ return 1
+end)
+]]
+
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
config.remove(nil, 'Lua.diagnostics.disable', 'unused-function')
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')