On 2/17/13, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:
> On 2/17/13, Nick Sabalausky <SeeWebsiteToContactMe@semitwist.com> wrote:
>> Hmm, that brings up a different (though minor) issue: If it's a
>> warning, why does it say "Error"?
>> I can see in the source there's a check for the -w flag but then an error is raised by mistake. This should either be an error regardless of -w or be changed into a warning.
>
Well the OP sample might also be a rejects-valid. So there's 2 bugs here.

On 2/17/13, Jonathan M Davis <jmdavisProg@gmx.com> wrote:
> Probably because -w turns warnings into errors. That's its whole schtick.
Really? Man this is confusing..
> However, -wi also appears to say "Error," which definitely isn't correct.
Ok good to know. I'm making a pull for these fixes.

On 2/18/13, Stewart Gordon <smjg_1998@yahoo.com> wrote:
> There's no such thing as an "empty case statement", unless you mean the case
> where the
> ScopeStatementList is ";" or "{}" by itself. Look at the grammar
> carefully.
>> So by the current spec, the first example is a syntax error, since a
> CaseStatement
> explicitly forbids another CaseStatement as its body.
The grammar and spec are often broken. The OP sample is completely valid.

On 17/02/2013 21:46, Jonathan M Davis wrote:
<snip>
>> Hmm, that brings up a different (though minor) issue: If it's a
>> warning, why does it say "Error"?
>> Probably because -w turns warnings into errors. That's its whole schtick.
No, the whole schtick of -w is that it causes warnings to be emitted at all. It's a quirk of the way it was designed that it treats them as errors - by returning a failure status code, not by the wording of the compiler output.
But it's clearly a bug that this particular warning message has the label "Error:" instead of "Warning:".
http://d.puremagic.com/issues/show_bug.cgi?id=952
Unless it really is meant to be an error, in which case it's a bug that it is emitted only if -w is used.
> However, -wi also appears to say "Error," which definitely isn't correct.
-wi versus -w shouldn't make any difference to the wording of error messages. Only to the status code returned by the compiler if there were any warnings.
Stewart.

On 18/02/2013 01:10, Andrej Mitrovic wrote:
<snip>
> The grammar and spec are often broken. The OP sample is completely valid.
The whole point of a spec is to define the language. So if the spec makes some code illegal, then (at least for the time being) it is illegal.
Stewart.

On Monday, February 18, 2013 01:04:41 Stewart Gordon wrote:
> On 17/02/2013 20:07, Jonathan M Davis wrote:
> <snip>
> > >> Implicit fall through shouldn't have been allowed from the beginning. It would appear that this has finally been banned.
> > > > Implicit fallthrough is a warning when a case stament is non-empty, but if it's empty (as in the example), then there is no warning.
> > What version of DMD are you using?
That's irrelevant. I'm stating what the intended behavior is. If the compiler doesn't follow that behavior, then it's a bug.
> You see, it's independent of whether there are any statements between the two case markers,
Which is a bug.
> and there's a further anomaly in that it's an _error_ that's emitted only if _warnings_ are enabled.
That's normal. That's what -w does. If you don't use any compiler flags, then you get no warnings. If you use -w, you get them, but they're treated as errors. If you use -wi, then you get "informational warnings" which is what most everyone expects compilers to do normally - i.e. print the warning but not treat it as an error - but Walter Bright thinks differently about such things than many people, and his compilers often don't do what many people would consider normal. He doesn't believe in warnings in the first place. Rather, he thinks that everything should be an error or not as far as the compiler is concerned (which I very much agree with), but unfortunately, he gave in enough to create the -w flag (and eventually, the -wi flag), and when he did, he didn't follow the behavior of your average compiler, which has generated a fair bit of confusion with regards to warnings.
> > If the compiler is warning about falling through an empty case statement, it's a bug.
> There's no such thing as an "empty case statement", unless you mean the case where the ScopeStatementList is ";" or "{}" by itself. Look at the grammar carefully.
> > So by the current spec, the first example is a syntax error, since a CaseStatement explicitly forbids another CaseStatement as its body.
I mean a case statement with no statements in it. The only thing following it is another case statement or the closing brace of the switch statement. That sort of fallthrough is not supposed to generate a warning. If the grammar claims anything about empty case statements being illegal, then the spec is in error (which happens far too often).
Walter has been very clear on the intended behavior. It's a warning to have implicit fallthrough except in the situation where the case statement is empty (because it would be very annoying to have to put a whole lot of gotos in case statements which are all supposed to shared the same code by falling through). If the compiler or grammar disagree with that, then it's a bug.
Actually, looking at the most recent compiler, it's generating a deprecation message now, so it's been moved from warning to deprecated, and it _is_ generating the message for an empty case statement, which is wrong.
- Jonathan M Davis

On Sun, 17 Feb 2013 20:28:51 -0500, Stewart Gordon <smjg_1998@yahoo.com> wrote:
> On 18/02/2013 01:10, Andrej Mitrovic wrote:
> <snip>
>> The grammar and spec are often broken. The OP sample is completely valid.
>> The whole point of a spec is to define the language. So if the spec makes some code illegal, then (at least for the time being) it is illegal.
It's quite possible the spec has a bug. It's not perfect.
-Steve