Bug 305 – version and static if blocks introduce new scope for 'scope' statement
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-08-23T00:11:00Z
Last change time
2014-02-15T13:20:33Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
sean
Comments
Comment #0 by sean — 2006-08-23T00:11:38Z
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