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)