Skip to content

Commit

Permalink
Merge pull request #3628 from 9rnsr/fix4791
Browse files Browse the repository at this point in the history
Issue 4791 - Assigning a static array to itself should be allowed
  • Loading branch information
9rnsr committed Jun 6, 2014
2 parents 9180ba2 + 4157e76 commit d2347f6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/runnable/assignable.d
Expand Up @@ -875,6 +875,35 @@ void test12211()
static assert(!__traits(compiles, bar(sa[] += sb[])));
}

/***************************************************/
// 4791 (dup of 12212)

void test4791()
{
int[2] na;
na = na;

static struct S
{
static string res;
int n;
this(this) { ++n; res ~= "p" ~ cast(char)('0' + n); }
~this() { res ~= "d" ~ cast(char)('0' + n); }
}
{
S[3] sa;
sa[0].n = 1, sa[1].n = 2, sa[2].n = 3;

S.res = null;
sa = sa;
assert(S.res == "p2d1p3d2p4d3");
assert(sa[0].n == 2 && sa[1].n == 3 && sa[2].n == 4);

S.res = null;
}
assert(S.res == "d4d3d2");
}

/***************************************************/
// 12212

Expand Down Expand Up @@ -1058,6 +1087,7 @@ int main()
test11187();
test12131();
test12211();
test4791();
test12212();
test12650();

Expand Down

0 comments on commit d2347f6

Please sign in to comment.