CT foreaches
Timon Gehr
timon.gehr at gmx.ch
Fri Aug 1 22:01:35 UTC 2025
On 8/1/25 20:06, Quirin Schroll wrote:
> On Friday, 1 August 2025 at 16:45:04 UTC, Nick Treleaven wrote:
>> On Friday, 1 August 2025 at 15:47:47 UTC, monkyyy wrote:
>>> On Friday, 1 August 2025 at 15:15:35 UTC, Nick Treleaven wrote:
>>>> The confusing thing is that enum there is silently ignored. I think
>>>> we could add an error for that.
>>>
>>> That would be a breaking change now, most code swapped from runtime
>>> to ct should continue working tho, better to just implement it
>>
>> Not really, no one should have used enum/alias with a non-static
>> ForeachRangeStatement because (as you pointed out), it wasn't in the
>> spec. If they did use it, they'd probably realize that those storage
>> classes had no effect.
>
> Making non-static `foreach (enum x; l .. u)` an error would be fairly
> easy. It’s just a parser issue. The error message could say: Use `static
> foreach`. I’ll have a go on this.
For reference:
https://github.com/dlang/dmd/issues/21630
https://github.com/dlang/dmd/pull/21631
https://github.com/dlang/dmd/pull/21633
My PR is currently blocked on a weird CI failure, not sure where it is
coming from.
More information about the Digitalmars-d
mailing list