www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8258] New: Delegates do not respect default parameters

reply d-bugmail puremagic.com writes:
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



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: -------
Jun 17 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8258


Mike Parker <aldacron gmail.com> changed:

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



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: -------
Jun 17 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8258




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: -------
Jun 17 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8258




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: -------
Jun 18 2012
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jul 22 2012