[Issue 13475] New: Incorrect overloading of immutable constructor for nested struct

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Sep 14 11:46:26 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13475

          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 at puremagic.com
          Reporter: andrei at erdani.com

Smoking gun:

struct A(T)
{
    struct B
    {
        this(size_t);

        this(size_t) immutable
        {
        }

        this(string s)
        {
            this(s.length);
        }
    }
}

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)
and:
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).

--


More information about the Digitalmars-d-bugs mailing list