Bug 9277 – [diagnostic] bad error message on illegal cast inside foreach

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-07T01:26:00Z
Last change time
2013-11-23T05:44:22Z
Keywords
ice
Assigned to
nobody
Creator
dmitry.olsh

Comments

Comment #0 by dmitry.olsh — 2013-01-07T01:26:56Z
On dmd 2.061 the following (illegal) program: void main() { class Int { int _val; this(int val){ _val = val; } } Int[] sink; foreach(v; 0..5_000) sink ~= [cast(Int)v]; //12 foreach(v; 0..5_000) sink ~= cast(Int)v; //14 } Produces: bug.d(12): Error: e2ir: cannot cast v of type int to type bug.main.Int bug.d(14): Error: e2ir: cannot cast v of type int to type bug.main.Int The awful 'e2ir:' part of message seems to only trigger if v is coming from foreach variable.
Comment #1 by andrej.mitrovich — 2013-01-07T09:08:40Z
Comment #2 by andrej.mitrovich — 2013-01-07T09:40:45Z
Pull was wrong, this was not a diagnostic problem. The 'e2ir' is a minor ICE, the error check should happen in the front-end. Once that is fixed this error message will improve.
Comment #3 by yebblies — 2013-11-23T05:44:22Z
And it's fixed by that patch. *** This issue has been marked as a duplicate of issue 11485 ***