foreach counter now must be size_t ?
Johan Engelen
j at j.nl
Mon Feb 4 22:26:08 UTC 2019
This code now gives a deprecation message (>= 2.084):
```
void foo(int[] arr) {
foreach (uint i, ref elem; arr) { }
}
```
Deprecation: foreach: loop index implicitly converted from
`size_t` to `uint`
This is in contrast to the spec that says that "The index must be
of int, uint, long or ulong type, it cannot be ref, and it is set
to be the index of the array element."
https://dlang.org/spec/statement.html#foreach_over_arrays
Did someone forget to update the spec? Or is it a frontend bug?
-Johan
More information about the Digitalmars-d
mailing list