summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lau <tomandfatboy@gmail.com>2024-08-27 14:22:19 +0800
committerTom Lau <tomandfatboy@gmail.com>2024-08-27 14:22:19 +0800
commitcd5ebb588118efa98dfe90f3ea485c00ea73c175 (patch)
tree98ada7a2f6d649ca4928e1c3235e35837cec74c1
parente09d181224da52fd6f82d228a8bcdffba58564d8 (diff)
downloadlua-language-server-cd5ebb588118efa98dfe90f3ea485c00ea73c175.zip
test: add tests for improved function type narrow
-rw-r--r--test/type_inference/param_match.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/type_inference/param_match.lua b/test/type_inference/param_match.lua
index 1079e433..906b9305 100644
--- a/test/type_inference/param_match.lua
+++ b/test/type_inference/param_match.lua
@@ -138,6 +138,40 @@ local function f(...) end
local <?r?> = f(10)
]]
+TEST '1' [[
+---@overload fun(a: string): 1
+---@overload fun(a: 'y'): 2
+local function f(...) end
+
+local <?r?> = f('x')
+]]
+
+TEST '2' [[
+---@overload fun(a: string): 1
+---@overload fun(a: 'y'): 2
+local function f(...) end
+
+local <?r?> = f('y')
+]]
+
+TEST '1' [[
+---@overload fun(a: string): 1
+---@overload fun(a: 'y'): 2
+local function f(...) end
+
+local v = 'x'
+local <?r?> = f(v)
+]]
+
+TEST '2' [[
+---@overload fun(a: string): 1
+---@overload fun(a: 'y'): 2
+local function f(...) end
+
+local v = 'y'
+local <?r?> = f(v)
+]]
+
TEST 'number' [[
---@overload fun(a: 1, c: fun(x: number))
---@overload fun(a: 2, c: fun(x: string))