[Issue 3646] Default values of function arguments are ignored when instantiating a template.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 3 08:53:41 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3646


Stewart Gordon <smjg at iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, spec
                 CC|                            |smjg at iname.com
            Version|2.035                       |1.051
             Blocks|                            |340
         OS/Version|Linux                       |All


--- Comment #3 from Stewart Gordon <smjg at iname.com> 2010-01-03 08:53:39 PST ---
I've never heard of default arguments being part of the function type's
properties.  I'd probably guessed that the type is simply void function(int)
but default arguments are filled in on the caller side.  In which case the
functions are the same type, and so this isn't meant to work.  Either way, it's
certainly a bug that the code is accepted.

And it applies to D1 too, but the code needs changing a bit:
----------
import std.stdio;

void foo(Fn)(Fn fn) {
    fn();
}

void bar(int i = 22) {
    writefln("bar ", i);
}
void bam(int i) {
    writefln("bam ", i);
}

void main() {
    foo(&bar);
    foo(&bam);
}
----------

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


More information about the Digitalmars-d-bugs mailing list