Skip to content

Commit

Permalink
Merge pull request #4054 from 9rnsr/fix11355
Browse files Browse the repository at this point in the history
Issue 11355 - Copy through alias this with @disabled this(this)
  • Loading branch information
yebblies committed Oct 8, 2014
2 parents 040515b + 1730307 commit d2ab695
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/expression.c
Expand Up @@ -11140,6 +11140,12 @@ Expression *AssignExp::semantic(Scope *sc)
return new ErrorExp();
}
}
else // Bugzilla 11355
{
Expression *e = op_overload(sc);
if (e)
return e;
}
}
else if (op == TOKassign)
{
Expand Down
29 changes: 29 additions & 0 deletions test/fail_compilation/fail11355.d
@@ -0,0 +1,29 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail11355.d(28): Error: struct fail11355.A is not copyable because it is annotated with @disable
---
*/

T move(T)(ref T source)
{
return T.init; // Dummy rvalue
}

struct A
{
~this() {}
@disable this(this); // Prevent copying
}

struct B
{
A a;
alias a this;
}

void main()
{
B b;
A a = move(b);
}
26 changes: 26 additions & 0 deletions test/runnable/aliasthis.d
Expand Up @@ -1727,6 +1727,31 @@ void test13490()
assert(t.a2 == [S13490(2)]);
}

/***************************************************/
// 11355

struct A11355
{
static int postblit;
this(this) { ++postblit; }
}

struct B11355
{
A11355 a;
alias a this;
}

B11355 make11355()
{
return B11355();
}
void test11355()
{
A11355 a1 = make11355();
assert(A11355.postblit == 1);
}

/***************************************************/

int main()
Expand Down Expand Up @@ -1781,6 +1806,7 @@ int main()
test11333();
test11800();
test13490();
test11355();

printf("Success\n");
return 0;
Expand Down

0 comments on commit d2ab695

Please sign in to comment.