Showing with 29 additions and 0 deletions.
  1. +14 −0 src/expression.c
  2. +15 −0 test/runnable/arrayop.d
14 changes: 14 additions & 0 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -11572,6 +11572,20 @@ Expression *AssignExp::semantic(Scope *sc)
if (e1x->checkPostblit(sc, t1))
return new ErrorExp();
}

// e2 matches to t1 because of the implicit length match, so
if (isUnaArrayOp(e2x->op) || isBinArrayOp(e2x->op))
{
// convert e1 to e1[]
// e.g. e1[] = a[] + b[];
e1x = new SliceExp(e1x->loc, e1x, NULL, NULL);
e1x = e1x->semantic(sc);
}
else
{
// convert e2 to t1 later
// e.g. e1 = [1, 2, 3];
}
}
else
{
Expand Down
15 changes: 15 additions & 0 deletions test/runnable/arrayop.d
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,20 @@ void test14649()
assert(r == [('a'+'d'), ('b'+'e'), ('c'+'f')]);
}

/************************************************************************/
// 14851

void test14851()
{
int[8] a, b, c;

c = a[] | b[]; // OK <- NG from 2.068.0-b2
c = a[] ^ b[]; // OK <- NG from 2.068.0-b2

c[] = a[] | b[]; // OK
c[] = a[] ^ b[]; // OK
}

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

int main()
Expand All @@ -905,6 +919,7 @@ int main()
test12780();
test13497();
test14649();
test14851();

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