www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13475] New: Incorrect overloading of immutable constructor


          Issue ID: 13475
           Summary: Incorrect overloading of immutable constructor for
                    nested struct
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: andrei erdani.com

Smoking gun:

struct A(T)
    struct B

        this(size_t) immutable

        this(string s)

void main()
    A!int s1;

This fails with:

test.d(15): Error: test.A!int.A.B.__ctor called with argument types (ulong)
matches both:
test.d(7):     test.A!int.A.B.this(ulong)
test.d(9):     test.A!int.A.B.this(ulong _param_0)
test.d(22): Error: template instance test.A!int error instantiating

Deleting the body of the immutable constructor oddly makes the error go away
(becomes a link-time error; adding a body for the first constructor makes the
program compile and link).

Sep 14 2014