diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2024-09-09 10:33:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-09 10:33:19 +0800 |
commit | d1320ae5e41086fd9f569c2504a88130447444b8 (patch) | |
tree | 26286c0fbed38d80d7c7b8efb36092c19b8544c7 /test | |
parent | c9d819305b6f88b53de294d54c820681518430c8 (diff) | |
parent | fe84a713afe4a37629cc95ca3d8a3e9c23be8eb8 (diff) | |
download | lua-language-server-d1320ae5e41086fd9f569c2504a88130447444b8.zip |
Merge pull request #2838 from tomlau10/fix/func_type_union_overload
Fix incorrect function params' type infer when there is only `@overload`
Diffstat (limited to 'test')
-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)) |