Postblit bug

IgorStepanov via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 16 17:42:24 PDT 2014


I've found a strange postblit bug (or not a bug?):

************************************

struct A
{
     this(this)
     {
     }
}

struct B
{
     A a;
}


struct C
{
     const B b;
}

void main()
{
     C c;
}

************************************

When I try to compile it, compiler raises the error: (Error: 
mutable method testaa2.B.__fieldPostBlit is not callable using a 
const object)

If I mark this(this) as const (BTW, is "this(this) const" a 
correct definition?) error still raises.
When I tried to reduce this code, I've found the next:

************************************

struct A
{
     this(this)
     {
     }
}

struct B
{
     const A a;
}


void main()
{
     B b;
}

************************************

Error: mutable method testaa2.A.__postblit is not callable using 
a const object

If I change this(this) to const, error has been lost.

************************************

struct A
{
     this(this) const
     {
     }
}

struct B
{
     const A a;
}


void main()
{
     B b;
}

************************************

Can someone comment this code? Should I think that it's a bug.


More information about the Digitalmars-d mailing list