effect of a label on following block

2010-11-15 Thread Nick Voronin
Hello. Consider this code void main() { l: { int v; } v = 5; // ok, v is defined } As I understand from D's grammar this behaviour is not a bug as LabeledStatement: Identifier : NoScopeStatement and NoScopeStatement in turn takes BlockStatement without creating new scope. It

Re: effect of a label on following block

2010-11-15 Thread Ellery Newcomer
My gut feeling is that the if statement's behavior is wrong and the while statement's is correct, but it could go either way. No need for a rationale for what can be adequately explained as a compiler bug (this is a downside of dmd - it trains you to think like this) It is curious, though, as

Re: effect of a label on following block

2010-11-15 Thread Ellery Newcomer
poking around a little more and I really don't know what's going on. fun piece of trivia though: while loops get rewritten to for loops, so for(;;) l1 { int v; } v = 4; exhibits the same behavior as the while loop. do loops seem to do the same thing as the if statement On 11/15/2010 10:34

Re: effect of a label on following block

2010-11-15 Thread bearophile
Ellery Newcomer: > No need for a rationale for what can be adequately explained as a > compiler bug (this is a downside of dmd - it trains you to think like > this) Or: Any sufficiently incomprehensible behaviour is indistinguishable from a DMD compiler bug :-) Bye, bearophile

Re: effect of a label on following block

2010-11-15 Thread div0
On 15/11/2010 16:45, Ellery Newcomer wrote: poking around a little more and I really don't know what's going on. fun piece of trivia though: while loops get rewritten to for loops, so for(;;) l1 { int v; } v = 4; exhibits the same behavior as the while loop. do loops seem to do the same thing

Re: effect of a label on following block

2010-11-16 Thread Nick Voronin
On Mon, 15 Nov 2010 19:34:46 +0300, Ellery Newcomer wrote: My gut feeling is that the if statement's behavior is wrong and the while statement's is correct, but it could go either way. I agree, I think case with 'when' works as specs say. No need for a rationale for what can be adequately

Re: effect of a label on following block

2010-11-16 Thread Stewart Gordon
On 16/11/2010 15:11, Nick Voronin wrote: There is still correct but unexpected behaviour. I found this on bugtracker http://d.puremagic.com/issues/show_bug.cgi?id=199 The rationale was "I don't want to change this because it could break existing code, and there doesn't seem to be a compelling re