October 21, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3430

           Summary: Cannot use constructor in member function default
                    argument
           Product: D
           Version: 1.00
          Platform: All
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: clugdbug@yahoo.com.au


--- Comment #0 from Don <clugdbug@yahoo.com.au> 2009-10-21 00:19:22 PDT ---
class Foo{
   this(int a){}
  static void bug(Foo a = new Foo(77)){}
}
test.d(4): Error: no constructor for Foo

This has been present since dinosaurs walked the earth(also failed in DMD
0.175).
Moving the function outside the class allows it to compile.

The struct version is D2 only:

struct Foo{
   this(int a){}
   void bug(Foo a = Foo(77)){}
}

test.d(4): Error: more initializers than fields of Foo

This is part of a family of closely related bugs.
If instead, the function is in a different struct/class, you get ICE bug 2437;
if it's a free function, you get ICE bug 2935.

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