Thank you for the report! This issue is actually not specific to the new type solver, and has been brought up before in the Luau open source repository, and definitely on the DevForum as well, but search functionality here is a bit tougher. We would really like to fix this, but there are at least a few things that need to happen before that can be possible. In the example you wrote, it’s immediately obvious that dictionary has a fixed collection of elements, and the type we assign to the key and value is clear, e.g. something : "hi" | "bye" and v : "good" | "bad". Unfortunately, it is not obvious in general. Consider this code in a function instead:
function frob(dictionary)
for key, value in dictionary do
print(string.match(key, "hi"))
end
end
Even if we annotate dictionary with a type, e.g.
function frob(dictionary: { hi: "bad", bye: "good" })
for key, value in dictionary do
print(string.match(key, "hi"))
end
end
It is still the case that we could call this function with a dictionary that has more things in it as well, e.g.
frob({hi: "bad", bye: "good", [1]: "foo"})
If we allowed this without error then, any code in the for loop would actually be assigning inaccurate types to key and value. Closing this soundness loophole would require us to instead say that the type of key and value are unknown, which would be accurate, but probably not particularly useful. So, today, our reasonable options are either: a) what we already do, which is give you an error and ask you to write an indexer on the dictionary type, or b) allow iteration, but the type of the fields is unknown and so you’ll still end up having to either cast or write conditionals that refine the type.
In order to do better here, we believe that it’s necessary to differentiate between table types that refer to the exact shape of the table, i.e. describe every field that is present and where the absence of a field in the type guarantees that it will not be present in the table, from the inexact table types that exist today. There’s been a long-standing RFC open for exactly this feature: Exact Table Types. For an exact table type, we could allow iteration and still provide a useful type for the keys and values. This RFC was iceboxed in order to focus on the New Type Solver without growing its scope even more than it already had, but exact table types are something we’re planning to implement in 2026, and you will be able to iterate over them with the expected behavior, even without specifying an indexer.
All that being said, for inexact table types, this is “by-design.” If you’d like to propose that Luau ought to give unknown, unknown instead, I’d say to open that as an RFC or a feature request and we can get various opinions on the two, but otherwise, the intention now is that inexact table types, which are the only kind we have today, will produce this error, and exact table types will not when they ship.