Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
July 17, 2009 [Issue 3187] New: Nested foreach over opApply doesn't work | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3187 Summary: Nested foreach over opApply doesn't work Product: D Version: unspecified Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: johnch_atms@hotmail.com Calling nested foreach statements on types that implement opApply causes an error. There appears to be a bug in the code generated by the compiler. class Collection { int opApply(int delegate(ref Object) a) { return 0; } } Object testForeach(Collection level1, Collection level2) { foreach (first; level1) { foreach (second; level2) return second; } return null; } void main() { testForeach(new Collection, new Collection); } Error: cannot implicitly convert expression (second) of type object.Object to int This is the code DMD generates for the testForeach method, with the problem line highlighted: Object testForeach(Collection level1, Collection level2) { switch(level1.opApply(delegate (Object __applyArg0) { { Object first = __applyArg0; switch(level2.opApply(delegate (Object __applyArg0) { { Object second = __applyArg0; { // ********* HERE'S THE PROBLEM ********* __result = cast(Object) cast(int) second; return 2; } } return 0; } )) { default: break; case 2: __result = __result; return 2; } } return 0; } )) { default: break; case 2: return __result; } return cast(Object) null; } This problem occurs with both DMD 1.x and 2.x compilers. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 06, 2010 [Issue 3187] Nested foreach over opApply doesn't work | ||||
---|---|---|---|---|
| ||||
Posted in reply to johnch_atms@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=3187 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|wrong-code |ice-on-valid-code --- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-08-06 00:05:14 PDT --- I'm changing this from wrong-code to ICE, since it never reaches code generation. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 16, 2011 [Issue 3187] Nested foreach over opApply doesn't work | ||||
---|---|---|---|---|
| ||||
Posted in reply to johnch_atms@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=3187 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|ice-on-valid-code |diagnostic, rejects-valid --- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-02-15 18:56:15 PST --- (In reply to comment #1) > I'm changing this from wrong-code to ICE, since it never reaches code generation. Actually although the compiler fouls this up badly, it isn't an ICE. It's a rejects-valid with a really bad diagnostic. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 01, 2011 [Issue 3187] Nested foreach over opApply doesn't work | ||||
---|---|---|---|---|
| ||||
Posted in reply to johnch_atms@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=3187 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch --- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2011-12-01 01:53:10 PST --- https://github.com/D-Programming-Language/dmd/pull/546 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 15, 2011 [Issue 3187] Nested foreach over opApply doesn't work | ||||
---|---|---|---|---|
| ||||
Posted in reply to johnch_atms@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=3187 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED --- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2011-12-14 18:42:37 PST --- https://github.com/D-Programming-Language/dmd/commit/514e1fa711a5774bf7c393772cd8489b2af2534e https://github.com/D-Programming-Language/dmd/commit/d124949381400582b5d6a6c5015bf42483afa54d -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 03, 2012 [Issue 3187] Nested foreach over opApply doesn't work | ||||
---|---|---|---|---|
| ||||
Posted in reply to johnch_atms@hotmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=3187 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |cbkbbejeap@mailinator.com --- Comment #5 from yebblies <yebblies@gmail.com> 2012-02-04 00:25:24 EST --- *** Issue 2192 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation