-
-
Notifications
You must be signed in to change notification settings - Fork 651
Issue 3144 - Invalid break accepted #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Force curly braces on switch statement's body.
For what it's worth, looks good to me. |
OK with me. I had mixed feelings about the language change but then I remembered each label introduces its own scope. So having a scope with the whole switch statement seems like a reasonable special case. |
@andralex This change is syntax only, switch statement semantics are unaffected. |
LGTM 👍 @9rnsr @dawgfoto what do you think folks? |
Will this break useful idioms like the following? enum Foo { a, b }
Foo foo;
final switch(foo) with(Foo)
{
case a:
...
break;
case b:
...
break;
} I know we could switch the statements so that with() is first here, but, a) LOTS of code already does it this way, and b) I think this way reads better. |
@JakobOvrum Yes it will break that, and I agree it shouldn't. |
Also, any spec updates to go with this pull request? |
@braddr No, I'm going to take that part out. |
I also sometimes use The right way to fix it is: If a switch statement has zero or one cases ( |
Yes, I've come to agree.
The bug I found 9 months ago was that dmd keeps searching for a closing I'm fairly sure 'zero cases' is already an error, but 'one case' is perfectly valid. |
OK, just now I have understand the root cause of the bug.
That's correct. I'd like to withdraw the point in my argument. |
I've opened another pull request #1182, which doesn't reject |
Fix enforce in popBack
Heh, turns out |
Force curly braces on switch statement's body.
It also disables the technically allowed but absolutely useless version:
I don't see any reason to allow this.
http://d.puremagic.com/issues/show_bug.cgi?id=3144