digitalmars.D.bugs - [Issue 4304] New: default arguments using delegates of a global object no longer work
- d-bugmail puremagic.com (45/45) Jun 13 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4304
- d-bugmail puremagic.com (13/13) Sep 13 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4304
http://d.puremagic.com/issues/show_bug.cgi?id=4304 Summary: default arguments using delegates of a global object no longer work Product: D Version: D1 Platform: Other OS/Version: Mac OS X Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: fawzi gmx.ch with dmd 1.062 {{{ class A{ int f(int a){ return a; } static A defaultA; static this(){ defaultA=new A(); } } void f(int delegate(int) arg=&A.defaultA.f){ arg(2); } void defaultCall(){ f(); } }}} fails with Error: cannot inline default argument &defaultA.f whereas it did work previously. This might be indeed correct if the compiler cannot guarantee that the correct value of defaultA is used (i.e. after the static initializer). It seemed to work correctly in my use case, and the fact that setting defaultA to another value is most probably not "seen" by default value shows that using null as default value, and an if (arg is null) arg=&A.defaultA.f; in the body is probably a better solution. I still submit it here, but most likely this change is a feature, not a bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 13 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4304 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug yahoo.com.au Resolution| |DUPLICATE Same root cause as bug 4820. *** This issue has been marked as a duplicate of issue 4820 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 13 2010