Thread overview
[Issue 8258] New: Delegates do not respect default parameters
Jun 17, 2012
Brad Anderson
Jun 17, 2012
Mike Parker
Jun 18, 2012
Mike Parker
Jun 19, 2012
Kenji Hara
Jul 22, 2012
Walter Bright
June 17, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8258

           Summary: Delegates do not respect default parameters
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: eco@gnuk.net


--- Comment #0 from Brad Anderson <eco@gnuk.net> 2012-06-17 02:08:40 PDT ---
This apparently works in dmd 2.059:

void foo(void delegate(int i, bool yes = true) dg)
{
   dg(1);
}

void main()
{
   void inner(int i, bool yes = true)
   {
   }
   foo(&inner);
}

but no longer works in dmd git HEAD 2.060.  I'm filing this on behalf of someone in IRC.  Aldacron may also know something about it too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 17, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8258


Mike Parker <aldacron@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aldacron@gmail.com


--- Comment #1 from Mike Parker <aldacron@gmail.com> 2012-06-17 03:26:08 PDT ---
Ah, well, I posted that in the Derelict forum in case someone wanted to try to minimize it. I don't know if it compiles as-is or not, but I've had two Derelict bug reports now with the following error using dmd master:

----
Error: expected 3 function arguments, not 2
----

In each case, the offending line is a call to a delegate that accepts a default parameter. I didn't want to report a bug until there was a reduced test case, but I don't want to mess around with compiling dmd from git. So I posted that piece of code hoping that a Derelict user would try it out with their dmdgit version to see what happens. It may, or may not, trigger the regression. I've no idea.

I was waiting for the beta release if no one got to it before then. But, since it's here, if anyone can see if the code works or not with git dmd...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8258



--- Comment #2 from Mike Parker <aldacron@gmail.com> 2012-06-17 21:50:12 PDT ---
OK, I just heard in #d that the call dg(1) in the above code snippet gives the following error with dmd-git:

Error: expected 2 function arguments, not 1

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8258



--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2012-06-18 18:55:22 PDT ---
I think this *regression* is introduced by fixing bug 3866.
Now all indirect calls do not consider default arguments even if it is written
in type signature.

I didn't join the discussion, but it seems to me that current *fix* is too conservative way - it rejects some useful cases like this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8258


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |DUPLICATE


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2012-07-22 13:08:12 PDT ---
Discussion should go in bug 3866.

*** This issue has been marked as a duplicate of issue 3866 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------