On 12/24/12 2:11 AM, bearophile wrote:
Recently Ada 2012 was accepted as ISO standard, and on the good Lambda
the Ultimate blog there is a small thread about it, with an interesting
post:

http://lambda-the-ultimate.org/node/4661#comment-73731

The post makes two simple valid points, worth considering.

Currently in D this code compiles with no errors:


void main() {
bool b;
final switch (b) {
case true:
break;
}
}


And gives at run-time:
core.exception.SwitchError@test(3): No appropriate switch clause found

It's one of my top fifteen bug reports (it was mislabelled as
enhancement request):
http://d.puremagic.com/issues/show_bug.cgi?id=5713

In my opinion It's a topic worth discussing and fixing.

Yes, this is a bug in the language design (as much as the "method is hidden" exception that I recall we got rid of).

The simplest solution is to statically disallow "final switch" to
operate on anything bug enums.

I'd say we eradicate the exception altogether. Again, it reflects incompleteness in language's approach. Requiring people to add a

default: {}

whenever they don't care about certain cases is a low price to pay for ensuring everybody stays in sync.


Andrei

Reply via email to