digitalmars.D.bugs - [Issue 3866] New: anonymous delegate with default parameters cross-talks to another anonymous delegate
- d-bugmail puremagic.com (31/31) Mar 01 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (10/10) Mar 18 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (13/13) Jul 03 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (18/18) Feb 11 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (13/13) Apr 25 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (33/33) Apr 26 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (9/9) Apr 26 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (9/9) Apr 26 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (9/9) Apr 27 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (10/10) Jul 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (10/10) Jul 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (10/10) Jul 25 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (21/21) Jul 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (10/10) Aug 04 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (10/10) Aug 06 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (18/18) Sep 05 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (11/11) Jul 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=3866
- d-bugmail puremagic.com (10/10) Jul 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=3866
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Summary: anonymous delegate with default parameters cross-talks to another anonymous delegate Product: D Version: 2.040 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: philippe.sigaud gmail.com 18:36:25 CET --- If you declare an anonymous delegate with default parameter, it affects another anonymous delegate with the same type: import std.stdio; void main() { auto foo = (int a = 1) { return a;}; auto bar = (int a) { return a;}; writeln(foo()); // writes '1' writeln(bar()); // writes '1' also! } It provokes (correctly) an error if bar is defined before foo: bar() called with 0 argument instead of 1. It does not affect delegate with another type auto baz = (double a) { return a;}; writeln(baz()); // Error, correct behaviour -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 01 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code CC| |clugdbug yahoo.com.au Severity|normal |critical -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 18 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3866 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch CC| |yebblies gmail.com Platform|Other |All OS/Version|Windows |All https://github.com/D-Programming-Language/dmd/pull/204 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 03 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3866 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|nobody puremagic.com |yebblies gmail.com The problem occurs because default parameters are stored in the type, but types are considered equivalent if their mangled names match, and mangled names don't include parameter names or default arguments. The solution is probably either to include parameter names and default arguments in the comparison for equality, or to move them out of function types and into function declarations. I'm leaning towards the latter. This case _can_ be fixed by refusing to merge function pointers, but the problem will still exists for pointers to function pointers, structs containing function pointers, etc. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 11 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla digitalmars.com 20:35:30 PDT --- Moving the default arguments out of the type and into the function declaration will resolve the problem, at the cost of you would no longer be able to have default arguments for function literals or any pointers to functions. Perhaps that's a good thing. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 25 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Jonathan M Davis <jmdavisProg gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg gmx.com PDT --- It was my understanding that default arguments were just arguments that were inserted when a function was called and you didn't provide all of the arguments. They aren't actually part of the signature or type at all. As such, they are only known if you call the function directly. If you use a function pointer (or delegate), then all you have is the signature, so you don't have any default arguments. As such, nested functions with default arguments such as static auto foo(int a = 1) { return a; } and auto foo(int a = 1) { return a + b; } should work just fine, but as with any function, as soon as you take their address or turn them into a delegate variable, their default arguments are lost. And so having default arguments in something like auto foo = (int a = 1) { return a;}; auto bar = (int a) { return a;}; is completely pointless, because all you have is a variable which knows the signature of the function/delegate to call. The function itself can't be called directly, so it doesn't have any default arguments associated with it, and so there's no point in the default arguments even being legal. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 26 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 23:06:52 PDT --- Leaving this as-is for D1 to avoid breaking existing code. For D2, changing behavior so that default args are part of the declaration, not the type, and so both function calls in the example are illegal, since calling through a function pointer now cannot have default args. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 26 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/acc22ce25db42facfe4917aeceabd28a410f4c95 fix Issue 3866 - anonymous delegate with default parameters cross-talks to another anonymous delegate -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 26 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 27 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |eco gnuk.net 13:08:12 PDT --- *** Issue 8258 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: -------
Jul 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sludwig outerproduct.org 23:01:48 PDT --- *** Issue 8430 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: -------
Jul 24 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |destructionator gmail.com 11:44:18 PDT --- *** Issue 8438 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: -------
Jul 25 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 17:37:07 PDT --- Personally I never used default values in delegates but I think this pull broke this real-world code from Derelict: void loadPlatformGL(void delegate(void**, string, bool doThrow = true) bindFunc) { bindFunc(null, "foo1"); bindFunc(null, "foo2"); // ... } In this case the default value is useful since it's only used from within the function, and it saves on typing since there are typically dozens of invocations of the delegate (in Derelict). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 30 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kolos80 bk.ru --- *** Issue 8402 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: -------
Aug 04 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |spam extrawurst.org 15:31:02 PDT --- *** Issue 8515 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: -------
Aug 06 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull Status|RESOLVED |REOPENED Resolution|FIXED | --- In the forum discussion: http://forum.dlang.org/thread/mailman.1421.1346020012.31962.digitalmars-d puremagic.com We decided to improve the status for default argument issues. Then I've created a new pull which contains some fixups for this issue. D2 pull: https://github.com/D-Programming-Language/dmd/pull/1102 So I reopen this for D2. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 05 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d7362898f16d7d5e04ac4e9f374a39a5e8e0ff53 Improved fix for Issue 3866 - anonymous delegate with default parameters cross-talks to another anonymous delegate This reverts commit acc22ce25db42facfe4917aeceabd28a410f4c95, and moves original test into runnable/functype.d -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2013
http://d.puremagic.com/issues/show_bug.cgi?id=3866 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Version|D1 & D2 |D2 Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 04 2013