luau-lang/luau

Variables pack not inferred correctly for `__iter` metamethod

Closed this issue · 0 comments

When iterating over a metatable that implements __iter, I expect the variables pack to be typed as the return type of the iterator function. Instead, they are inferred as any.

local it = setmetatable({}, {__iter = function() 
    return function() 
        return 1, 2, 3
    end
end })
for id, test in it do 
    -- id and test are `any`. It should be `number, number`
    print(test)
end