May 21, 2010 [Issue 4218] New: safe function cannot call opApply | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4218 Summary: safe function cannot call opApply Product: D Version: 2.041 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: zan77137@nifty.com --- Comment #0 from SHOO <zan77137@nifty.com> 2010-05-21 10:33:41 PDT --- This code doesn't work! -------------------------------------------- struct S{ @safe int opApply(scope int delegate(ref int) dg){return 0;} } @safe void main() { S s; foreach (x; s) {} } -------------------------------------------- @safe delegate can implicit convert to @system delegate. Following code can compile: -------------------------------------------- struct S{ @safe void foo(){} } @safe void main() { S s; void delegate() dg = &s.foo; } -------------------------------------------- And of course, "int delegate(ref int) @safe" should convert to "int delegate(ref int)". Therefore, safe function should allow to call opApply. Workaround is here: -------------------------------------------- struct S{ @safe int opApply(scope int delegate(ref int) dg){return 0;} @safe int opApply(scope int delegate(ref int)@safe dg){return 0;} } @safe void foo() { S s; foreach (x; s) {} } @system void main() { S s; foreach (x; s) {} foo(); } -------------------------------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 13, 2011 [Issue 4218] safe function cannot call opApply | ||||
---|---|---|---|---|
| ||||
Posted in reply to SHOO | http://d.puremagic.com/issues/show_bug.cgi?id=4218 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies@gmail.com Resolution| |DUPLICATE --- Comment #1 from yebblies <yebblies@gmail.com> 2011-06-13 12:16:14 PDT --- The underlying issue a dupe of bug 3180. *** This issue has been marked as a duplicate of issue 3180 *** -- 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