[Issue 5714] case ranges in final switches
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 2 16:00:23 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=5714
Bolpat <qs.il.paperinik at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |qs.il.paperinik at gmail.com
--- Comment #5 from Bolpat <qs.il.paperinik at gmail.com> ---
The limitation of the number of `case` labels is entirely orthogonal to
allowing case ranges for `final switch`, as the ranges are just syntactic sugar
for writing them out.
This errors:
---
void main()
{
ubyte u;
final switch (u)
{
case 0: .. case 100: break;
case 101: .. case 255: break;
}
}
---
This is fine:
---
void main() {
ubyte u;
Lswitch: final switch (u)
{
static foreach (i; 0 .. 100 + 1)
{
case i: break Lswitch;
}
static foreach (i; 101 .. 255 + 1)
{
case i: break Lswitch;
}
}
}
---
The error makes no sense. It might have made sense in 2011, but in 2024, it
just requires some boilerplate to work.
--
More information about the Digitalmars-d-bugs
mailing list