www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4313] New: undefined identifier error with scope guard statement

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4313

           Summary: undefined identifier error with scope guard statement
           Product: D
           Version: 2.041
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: mrmocool gmx.de


--- Comment #0 from Trass3r <mrmocool gmx.de> 2010-06-14 11:45:44 PDT ---
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".

The question is, if this case is an accepts-invalid or if the other two cases
are rejects-valid.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 14 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4313


Trass3r <mrmocool gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid


--- Comment #1 from Trass3r <mrmocool gmx.de> 2010-06-14 12:47:08 PDT ---
Seems a bit strange. According to CompoundStatement::semantic this is rewritten
as try-catch-finally.

Even scope(exit) would have the auto res = 0 in the try block which would
result in undefined identifier.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 14 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4313


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com
            Version|2.041                       |D1 & D2


--- Comment #2 from yebblies <yebblies gmail.com> 2012-01-31 14:02:11 EST ---
(In reply to comment #1)
 Seems a bit strange. According to CompoundStatement::semantic this is rewritten
 as try-catch-finally.
 
 Even scope(exit) would have the auto res = 0 in the try block which would
 result in undefined identifier.
Because the declaration is nothrow, main's body becomes: { int res = 0; writeln(res); return 0; } But yes, this is a bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 30 2012