TEST 'boolean' [[ ---@overload fun(x: number, y: number):string ---@overload fun(x: number):number ---@return boolean local function f() end local = f() local n2 = f(0) local n3 = f(0, 0) ]] TEST 'number' [[ ---@overload fun(x: number, y: number):string ---@overload fun(x: number):number ---@return boolean local function f() end local n1 = f() local = f(0) local n3 = f(0, 0) ]] TEST 'string' [[ ---@overload fun(x: number, y: number):string ---@overload fun(x: number):number ---@return boolean local function f() end local n1 = f() local n2 = f(0) local = f(0, 0) ]] TEST 'boolean' [[ ---@overload fun():boolean ---@param x integer ---@return number function f(x) end local = f() ]] TEST 'number' [[ ---@overload fun():boolean ---@param x integer ---@return number function f(x) end local = f(1) ]] TEST 'boolean' [[ ---@overload fun():boolean ---@param x integer ---@return number function f(x) end function r0() return end local = f(r0()) ]] TEST 'number' [[ ---@overload fun():boolean ---@param x integer ---@return number function f(x) end function r1() return 1 end local = f(r1()) ]] TEST 'boolean' [[ ---@overload fun():boolean ---@param x integer ---@return number function f(x) end ---@type fun() local r0 local = f(r0()) ]] TEST 'number' [[ ---@overload fun():boolean ---@param x integer ---@return number function f(x) end ---@type fun():integer local r1 local = f(r1()) ]] TEST '1' [[ ---@overload fun(a: 'x'): 1 ---@overload fun(a: 'y'): 2 local function f(...) end local = f('x') ]] TEST '2' [[ ---@overload fun(a: 'x'): 1 ---@overload fun(a: 'y'): 2 local function f(...) end local = f('y') ]] TEST '1' [[ ---@overload fun(a: boolean): 1 ---@overload fun(a: number): 2 local function f(...) end local = f(true) ]] TEST '2' [[ ---@overload fun(a: boolean): 1 ---@overload fun(a: number): 2 local function f(...) end local = f(10) ]] TEST '1' [[ ---@overload fun(a: string): 1 ---@overload fun(a: 'y'): 2 local function f(...) end local = f('x') ]] TEST '2' [[ ---@overload fun(a: string): 1 ---@overload fun(a: 'y'): 2 local function f(...) end local = f('y') ]] TEST '1' [[ ---@overload fun(a: string): 1 ---@overload fun(a: 'y'): 2 local function f(...) end local v = 'x' local = f(v) ]] TEST '2' [[ ---@overload fun(a: string): 1 ---@overload fun(a: 'y'): 2 local function f(...) end local v = 'y' local = f(v) ]] TEST 'string|number' [[ ---@overload fun(a: string) ---@overload fun(a: number) local function f() end ]] TEST '1|2' [[ ---@overload fun(a: 1) ---@overload fun(a: 2) local function f() end ]] TEST 'string' [[ ---@overload fun(a: 1): string ---@overload fun(a: 2): number local function f(a) end local = f(1) ]] TEST 'number' [[ ---@overload fun(a: 1): string ---@overload fun(a: 2): number local function f(a) end local = 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 = f(v) ]] TEST 'number' [[ ---@overload fun(a: 1, c: fun(x: number)) ---@overload fun(a: 2, c: fun(x: string)) local function f(...) end f(1, function () end) ]] TEST 'string' [[ ---@overload fun(a: 1, c: fun(x: number)) ---@overload fun(a: 2, c: fun(x: string)) local function f(...) end f(2, function () end) ]] TEST 'any' [[ ---@overload fun(a: 1) ---@overload fun(a: 2) local function f(...) end f(1, function () end) ]]