Skip to content

Commit 54f1bac

Browse files
committed
test: add test cases for new overload type match behavior
1 parent 9794cc4 commit 54f1bac

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/type_inference/param_match.lua

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,44 @@ local v = 'y'
172172
local <?r?> = f(v)
173173
]]
174174

175+
TEST 'string|number' [[
176+
---@overload fun(a: string)
177+
---@overload fun(a: number)
178+
local function f(<?a?>) end
179+
]]
180+
181+
TEST '1|2' [[
182+
---@overload fun(a: 1)
183+
---@overload fun(a: 2)
184+
local function f(<?a?>) end
185+
]]
186+
187+
TEST 'string' [[
188+
---@overload fun(a: 1): string
189+
---@overload fun(a: 2): number
190+
local function f(a) end
191+
192+
local <?r?> = f(1)
193+
]]
194+
195+
TEST 'number' [[
196+
---@overload fun(a: 1): string
197+
---@overload fun(a: 2): number
198+
local function f(a) end
199+
200+
local <?r?> = f(2)
201+
]]
202+
203+
TEST 'string|number' [[
204+
---@overload fun(a: 1): string
205+
---@overload fun(a: 2): number
206+
local function f(a) end
207+
208+
---@type number
209+
local v
210+
local <?r?> = f(v)
211+
]]
212+
175213
TEST 'number' [[
176214
---@overload fun(a: 1, c: fun(x: number))
177215
---@overload fun(a: 2, c: fun(x: string))

0 commit comments

Comments
 (0)