← Back to index
|
Original Bugzilla link
Bug 9172 – strange shadowing declaration check
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-17T12:56:00Z
Last change time
2013-01-26T06:17:06Z
Assigned to
nobody
Creator
atankeev
Comments
Comment #0
by atankeev — 2012-12-17T12:56:47Z
DMD64 D Compiler v2.060 ---{ testcase.d }--- import std.random; void main() { if ( uniform(0,1) ) for(uint i=0; i < 1; i++) if ( uniform(0,1) ) {} else for(uint i=0; i < 1; i++) if ( uniform(0,1) ) {} } ------{ EOF }------- # rdmd testcase.d testcase.d(8): Error: shadowing declaration testcase.main.i is deprecated ---{ testcase.d }--- import std.random; import std.stdio; void main() { if ( uniform(0,1) ) for(uint i=0; i < 1; i++) writeln(1);//if ( uniform(0,1) ) {} else for(uint i=0; i < 1; i++) writeln(2);//if ( uniform(0,1) ) {} } ------{ EOF }------- # rdmd testcase.d 2
Comment #1
by bearophile_hugs — 2012-12-17T13:09:30Z
It's a dangling else. Always compile with -w or -wi. This issue should be closed.
Comment #2
by atankeev — 2012-12-17T13:14:46Z
Oops. My bad, sorry.