summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2024-09-09 10:34:34 +0800
committerGitHub <noreply@github.com>2024-09-09 10:34:34 +0800
commit7784a06294c4ced20444ab258ca09833bb6b0f7e (patch)
tree4d10fc7ce75ff7ea13f46a90608574e66fed121c /test
parent0cbaf86b58942da5644377a4a6198ed8f8b5eee3 (diff)
parentd1320ae5e41086fd9f569c2504a88130447444b8 (diff)
downloadlua-language-server-7784a06294c4ced20444ab258ca09833bb6b0f7e.zip
Merge branch 'master' into fix-autocompletion-arg-for-func-overload
Diffstat (limited to 'test')
-rw-r--r--test/type_inference/param_match.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/type_inference/param_match.lua b/test/type_inference/param_match.lua
index 906b9305..21dcf4d3 100644
--- a/test/type_inference/param_match.lua
+++ b/test/type_inference/param_match.lua
@@ -172,6 +172,44 @@ local v = 'y'
local <?r?> = f(v)
]]
+TEST 'string|number' [[
+---@overload fun(a: string)
+---@overload fun(a: number)
+local function f(<?a?>) end
+]]
+
+TEST '1|2' [[
+---@overload fun(a: 1)
+---@overload fun(a: 2)
+local function f(<?a?>) end
+]]
+
+TEST 'string' [[
+---@overload fun(a: 1): string
+---@overload fun(a: 2): number
+local function f(a) end
+
+local <?r?> = f(1)
+]]
+
+TEST 'number' [[
+---@overload fun(a: 1): string
+---@overload fun(a: 2): number
+local function f(a) end
+
+local <?r?> = f(2)
+]]
+
+TEST 'string|number' [[
+---@overload fun(a: 1): string
+---@overload fun(a: 2): number
+local function f(a) end
+
+---@type number
+local v
+local <?r?> = f(v)
+]]
+
TEST 'number' [[
---@overload fun(a: 1, c: fun(x: number))
---@overload fun(a: 2, c: fun(x: string))