www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 305] New: version and static if blocks introduce new scope for 'scope' statement

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

           Summary: version and static if blocks introduce new scope for
                    'scope' statement
           Product: D
           Version: 0.165
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: sean f4.ca


According to the documentation for version blocks, "no new scope is introduced,
even if the DeclarationBlock or Statement is enclosed by { }."  And the docs
for static if say "it does not introduce a new scope even if { }  are used for
conditionally compiled statements."  However, this code:

void main()
{
    version( all )
    {
        scope( exit ) printf( "version exit\n" );
    }
    static if( true )
    {
        scope( exit ) printf( "if exit\n" );
    }
    printf( "main\n" );
}

Produces this output:

version exit
if exit
main

When I expect:

main
if exit
version exit


-- 
Aug 22 2006
next sibling parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com schrieb am 2006-08-23:
 http://d.puremagic.com/issues/show_bug.cgi?id=305
 According to the documentation for version blocks, "no new scope is introduced,
 even if the DeclarationBlock or Statement is enclosed by { }."  And the docs
 for static if say "it does not introduce a new scope even if { }  are used for
 conditionally compiled statements."  However, this code:

 void main()
 {
     version( all )
     {
         scope( exit ) printf( "version exit\n" );
     }
     static if( true )
     {
         scope( exit ) printf( "if exit\n" );
     }
     printf( "main\n" );
 }

 Produces this output:

 version exit
 if exit
 main

 When I expect:

 main
 if exit
 version exit
Added to DStress as http://dstress.kuehne.cn/run/v/version_38_A.d http://dstress.kuehne.cn/run/v/version_38_B.d http://dstress.kuehne.cn/run/v/version_38_C.d http://dstress.kuehne.cn/run/v/version_38_D.d http://dstress.kuehne.cn/run/v/version_38_E.d http://dstress.kuehne.cn/run/s/static_if_07_A.d http://dstress.kuehne.cn/run/s/static_if_07_B.d http://dstress.kuehne.cn/run/s/static_if_07_C.d http://dstress.kuehne.cn/run/s/static_if_07_D.d http://dstress.kuehne.cn/run/s/static_if_07_E.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFE7uYQLK5blCcjpWoRAvVaAJ9GX6hfQrSN09bMoiwUF2fzZAmc9wCcCMbb YF41KGZDMBSclrhyPmCBqXM= =Ynxt -----END PGP SIGNATURE-----
Aug 25 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=305


thomas-dloop kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




-- 
Jan 01 2007