summaryrefslogtreecommitdiff
path: root/test/type_inference
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2024-05-11 18:10:56 +0800
committer最萌小汐 <sumneko@hotmail.com>2024-05-11 18:10:56 +0800
commit34de616ca2a14104782ec54fb33183d7e1d4a947 (patch)
tree37c302614cd6e592f3688e6dd31e289208d5ffc5 /test/type_inference
parent6fb7e1861af8d287229146c2357787c8e25b0832 (diff)
downloadlua-language-server-34de616ca2a14104782ec54fb33183d7e1d4a947.zip
支持根据参数类型选择函数定义
Diffstat (limited to 'test/type_inference')
-rw-r--r--test/type_inference/param_match.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/type_inference/param_match.lua b/test/type_inference/param_match.lua
index 3bb167bc..8ead05ef 100644
--- a/test/type_inference/param_match.lua
+++ b/test/type_inference/param_match.lua
@@ -105,3 +105,35 @@ local r1
local <?x?> = f(r1())
]]
+
+TEST '1' [[
+---@overload fun(a: 'x'): 1
+---@overload fun(a: 'y'): 2
+local function f(...) end
+
+local <?r?> = f('x')
+]]
+
+TEST '2' [[
+---@overload fun(a: 'x'): 1
+---@overload fun(a: 'y'): 2
+local function f(...) end
+
+local <?r?> = f('y')
+]]
+
+TEST '1' [[
+---@overload fun(a: boolean): 1
+---@overload fun(a: number): 2
+local function f(...) end
+
+local <?r?> = f(true)
+]]
+
+TEST '2' [[
+---@overload fun(a: boolean): 1
+---@overload fun(a: number): 2
+local function f(...) end
+
+local <?r?> = f(10)
+]]