Bug 2541 – cannot use aliased type for decl of foreach variable

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-12-26T08:35:00Z
Last change time
2015-06-09T01:20:50Z
Assigned to
nobody
Creator
adolf.mathias

Comments

Comment #0 by adolf.mathias — 2008-12-26T08:35:21Z
The following program alias uint Uint; void main() { foreach(Uint u;1..10) {} for(Uint u=1;u<10;u++) {} } fails with the messages bug.d(4): Error: forward reference to type Uint bug.d(4): Error: cannot implicitly convert expression (1) of type int to Uint bug.d(4): Error: forward reference to type Uint bug.d(4): Error: cannot implicitly convert expression (10) of type int to Uint bug.d(4): Error: Uint is not a scalar type All similar attempts produced the same messages. Funny that the simple for loop and foreach with builtin types work.
Comment #1 by smjg — 2009-01-11T17:07:35Z
WFM 2.023 Windows. Can you still reproduce on Linux?
Comment #2 by smjg — 2009-08-25T11:11:45Z
No reply => WFM