summaryrefslogtreecommitdiff
path: root/test/type_inference/init.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-10-23 02:21:17 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-10-23 02:21:17 +0800
commit96b320247788163f7d014404b7b1f089aed82dff (patch)
tree888558c3cfdc44e427e0f558d071897e38368f18 /test/type_inference/init.lua
parentb6e7d271fcb9c6d807a196d333cd27b920d71f9e (diff)
downloadlua-language-server-96b320247788163f7d014404b7b1f089aed82dff.zip
infer type by function as parameters
resolve #1153
Diffstat (limited to 'test/type_inference/init.lua')
-rw-r--r--test/type_inference/init.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 43177dc7..de42a91d 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -3803,3 +3803,58 @@ local class
class.has.nested.<?fn?>()
]]
+
+TEST 'integer[]' [[
+---@generic T
+---@param f fun(x: T)
+---@return T[]
+local function x(f) end
+
+---@param x integer
+local <?arr?> = x(function (x) end)
+]]
+
+TEST 'integer[]' [[
+---@generic T
+---@param f fun():T
+---@return T[]
+local function x(f) end
+
+local <?arr?> = x(function ()
+ return 1
+end)
+]]
+
+TEST 'integer[]' [[
+---@generic T
+---@param f fun():T
+---@return T[]
+local function x(f) end
+
+---@return integer
+local <?arr?> = x(function () end)
+]]
+
+TEST 'integer[]' [[
+---@generic T
+---@param f fun(x: T)
+---@return T[]
+local function x(f) end
+
+---@type fun(x: integer)
+local cb
+
+local <?arr?> = x(cb)
+]]
+
+TEST 'integer[]' [[
+---@generic T
+---@param f fun():T
+---@return T[]
+local function x(f) end
+
+---@type fun(): integer
+local cb
+
+local <?arr?> = x(cb)
+]]