Bug 8258 – Delegates do not respect default parameters
Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-17T02:08:00Z
Last change time
2012-07-22T13:08:12Z
Assigned to
nobody
Creator
eco
Comments
Comment #0 by eco — 2012-06-17T02:08:40Z
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.
Comment #1 by aldacron — 2012-06-17T03:26:08Z
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...
Comment #2 by aldacron — 2012-06-17T21:50:12Z
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
Comment #3 by k.hara.pg — 2012-06-18T18:55:22Z
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.
Comment #4 by bugzilla — 2012-07-22T13:08:12Z
Discussion should go in bug 3866.
*** This issue has been marked as a duplicate of issue 3866 ***