Skip to content

Commit cd5ebb5

Browse files
committed
test: add tests for improved function type narrow
1 parent e09d181 commit cd5ebb5

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/type_inference/param_match.lua

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,40 @@ local function f(...) end
138138
local <?r?> = f(10)
139139
]]
140140

141+
TEST '1' [[
142+
---@overload fun(a: string): 1
143+
---@overload fun(a: 'y'): 2
144+
local function f(...) end
145+
146+
local <?r?> = f('x')
147+
]]
148+
149+
TEST '2' [[
150+
---@overload fun(a: string): 1
151+
---@overload fun(a: 'y'): 2
152+
local function f(...) end
153+
154+
local <?r?> = f('y')
155+
]]
156+
157+
TEST '1' [[
158+
---@overload fun(a: string): 1
159+
---@overload fun(a: 'y'): 2
160+
local function f(...) end
161+
162+
local v = 'x'
163+
local <?r?> = f(v)
164+
]]
165+
166+
TEST '2' [[
167+
---@overload fun(a: string): 1
168+
---@overload fun(a: 'y'): 2
169+
local function f(...) end
170+
171+
local v = 'y'
172+
local <?r?> = f(v)
173+
]]
174+
141175
TEST 'number' [[
142176
---@overload fun(a: 1, c: fun(x: number))
143177
---@overload fun(a: 2, c: fun(x: string))

0 commit comments

Comments
 (0)