D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3394 - enum + for loop = strange errors
Summary: enum + for loop = strange errors
Status: RESOLVED DUPLICATE of issue 3190
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-13 09:10 UTC by David Simcha
Modified: 2015-06-09 01:28 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2009-10-13 09:10:38 UTC
enum FOO = 2;

void main() {
    for(uint i = 0; i < 2; i += FOO) {}
}

Results in a compile time error:

test.d(4): Error: variable FOO used before set

Marking as minor because it appears to be an extremely weird corner case bug.  The only place I could reproduce it was when the enum is used in a for loop like the above.

Also, changing FOO from enum to immutable resolves this.
Comment 1 Don 2009-10-13 09:12:18 UTC
Already patched.

*** This issue has been marked as a duplicate of issue 3190 ***