Luau !strict type checker raises a warning when trying to iterate over a empty table without a iterator function

In !strict mode, when you iterate over a empty table without a iterator function (e.g. ipairs, pairs), the type checker raises a warning about needing a iterator.

However, when doing the same thing but when the table has data in it, the code isn’t flagged. I don’t think this is expected behavior.

For example, this code should not get flagged:

--!strict
local x = {}
for iterator, value in x do
	print(value)
end

But this code doesn’t get flagged:

--!strict
local y = {"Hello", "world!"}
for iterator, value in y do
	print(value)
end

Edit: fixed repro code to use the --!strict tag

EmptyTableNoIterator.rbxl (53.1 KB)

We’ve filed a ticket to our internal database, and we’ll follow up when we have an update!

Thanks for the report!

This should be fixed! Sorry for the late update here.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.