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 looks very unnatural for me though. Especially when label goes before ThenStatement

if(1)
l1:{
  int v;
}
v = 5;

it works as above, yet label after 'while'

while(1)
l1:{
  int v;
}
v = 5; // error, v is undefined

has no such effect, even if ThenStatement is just another ScopeStatement. I don't understand this difference. Any rationale behind this?

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to