diff options
author | Tom Lau <tomandfatboy@gmail.com> | 2024-09-06 11:18:20 +0800 |
---|---|---|
committer | Tom Lau <tomandfatboy@gmail.com> | 2024-09-07 10:37:24 +0800 |
commit | 54f1bac0815c0e51494f057282984d173469838f (patch) | |
tree | 03a72ebec4c6f7511b21857ad593eb3fd13909d7 | |
parent | 9794cc44b6524f0d3bc4e0bab59275745802366b (diff) | |
download | lua-language-server-54f1bac0815c0e51494f057282984d173469838f.zip |
test: add test cases for new overload type match behavior
-rw-r--r-- | test/type_inference/param_match.lua | 38 |
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)) |