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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 25 01:02:51 PST 2009


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

           Summary: Default values of function arguments are ignored when
                    instantiating a template.
           Product: D
           Version: 2.035
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: e.insafutdinov at gmail.com


--- Comment #0 from Eldar Insafutdinov <e.insafutdinov at gmail.com> 2009-12-25 01:02:49 PST ---
void foo(Fn)(Fn fn)
{
    fn();
}

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

void baz() {
    foo(&bar);
    foo(&bam);
}

This code compiles while it should not. You cannot call bam() without any
arguments. If you switch the instantiations and call foo(&bam) first - it does
not compile.


pragma(msg, typeof(&bar).stringof);
pragma(msg, typeof(&bam).stringof);

outputs

void function(int i = 22)
void function(int i)


But it is not respected by the template.

-- 
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