www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - undefined identifier with scope statement?

reply Trass3r <un known.com> writes:
import std.stdio;

void main()
{
	scope(exit) writeln(res);
	
	auto res = 0;
}

This compiles, but using failure or success in the scope guard statement  
gives "undefined identifier res".
Is this intended? If yes, why?
Jun 13 2010
parent reply BCS <none anon.com> writes:
Hello Trass3r,

 import std.stdio;
 
 void main()
 {
 scope(exit) writeln(res);
 auto res = 0;
 }
 This compiles, but using failure or success in the scope guard
 statement
 gives "undefined identifier res".
 Is this intended? If yes, why?
I'm going to guess that the given case is an accepts-invalid bug caused by scope getting re written as a try/finally with the writeln at the bottom of some scope containing res and the other cases put it outside the scope. File a bug and see what happens. -- ... <IXOYE><
Jun 13 2010
parent Trass3r <un known.com> writes:
 I'm going to guess that the given case is an accepts-invalid bug caused  
 by scope getting re written as a try/finally with the writeln at the  
 bottom of some scope containing res and the other cases put it outside  
 the scope. File a bug and see what happens.
http://d.puremagic.com/issues/show_bug.cgi?id=4313
Jun 14 2010