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
Comment #1 by thomas-dloop — 2006-08-25T06:55:33Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] 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-----