When iterating in the new typechecker, no matter what, the value field in the iteration always ends up being this type “V”. This causes the typechecker to freak out when using strict mode. This only happens when using next
as an iterator.
here’s an example:
--!strict
--I used tables as they are the closest to instances, which I am experiencing the issue with
--this does also happen for this example though
local tbl = {
{3, 5, 7},
{5, 2, 1},
{2, 6, 3}
}
for i, v in next, tbl, nil do
v --> when holding "v" for autocomplete, it comes as "V"
v.someKey = 3 --> "Cannot add field 'someKey' to table V"
end
for i, v: {number} in next, tbl, nil do
v --> when holding for autocomplete now, v does show as {number}
v.someKey = 3 --> "Cannot add field 'someKey' to table V"
end
This does not only happen for array-like data structures, but also dictionaries. It also only happens when I use the next
iterator. No matter what type annotation methods I use, for example on the table as well, the warning still shows.
Applied example:
(image so warnings show)
These warnings are the same as I showed above:
How to reproduce:
- Open up a script
- Type in the code example I showed above
- Hold v for autocomplete, replicates the behaviour I said about above
- See strict mode warnings
System info:
- OS: Windows 11, version 24H2
- Processor: 11th Gen Intel(R) Core™ i5-1135G7 @ 2.40GHz 2.42 GHz
- 8GB RAM
- Built-in GPU (idk sorry)
Expected behavior
Iteration variables should be correctly type’d.