You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
type is lost when using param in the return statement of lambda with generic return #910
It seems like the type for a parameter is lost if it's used in the return statement of a lambda function with a generic parameter, and return (i.e. fun<T, U>(v: T): U):
--- @genericT--- @param ... T...--- @returnT...localfunctionidentity(...) return...end--- @genericT,U--- @paramlistT[]--- @paramfnfun(item: T): U--- @returnU[]localfunctionmap(list, fn) returnnil--[[@as U[] ]]endlocallist_1--- @typestring[]local_mapped_1=-- ^ type: `int[]` ✅map(list_1, function(item)
local_a=identity(item)
-- ^ type: `string` ✅-- The type is correct while the param doesn't appear in the return-- statement.return42end)
local_mapped_2=-- ^ type: `any[]` ❌ should be `string[]`map(list_1, function(item)
local_a=identity(item)
-- ^ type: `any` ❌-- The type is lost if the param is used in the return statement.returnitemend)
local_mapped_3=-- ^ type: `string[]` ✅map(list_1, function(item)
local_a=identity(item)
-- ^ type: `string` ✅-- The type is correct if the return is explicitly typed.returnitem--[[@as string ]]end)
Activity
fix(generic): infer inline lambda return for callback generics