Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix Issue 9248 - [2.061 beta] Concatenation of array literal and arra…

…y produces corrupted result
  • Loading branch information...
commit 5b8d3b7e6537601f2f914d1109d85e8686f02098 1 parent dc2ec0f
@WalterBright WalterBright authored
Showing with 25 additions and 1 deletion.
  1. +14 −1 src/expression.c
  2. +11 −0 test/runnable/test42.d
View
15 src/expression.c
@@ -11436,7 +11436,20 @@ Expression *CatExp::semantic(Scope *sc)
Type *tb1next = tb1->nextOf();
Type *tb2next = tb2->nextOf();
- if ((tb1->ty == Tsarray || tb1->ty == Tarray) &&
+ if (tb1next && tb2next &&
+ (tb1next->implicitConvTo(tb2next) >= MATCHconst ||
+ tb2next->implicitConvTo(tb1next) >= MATCHconst)
+ )
+ {
+ /* Here to avoid the case of:
+ * void*[] a = [cast(void*)1];
+ * void*[] b = [cast(void*)2];
+ * a ~ b;
+ * becoming:
+ * a ~ [cast(void*)b];
+ */
+ }
+ else if ((tb1->ty == Tsarray || tb1->ty == Tarray) &&
e2->implicitConvTo(tb1next) >= MATCHconvert)
{
checkPostblit(e2->loc, tb2);
View
11 test/runnable/test42.d
@@ -5444,6 +5444,16 @@ void test9171()
/***************************************************/
+void test9248()
+{
+ void*[] a = [cast(void*)1];
+ void*[] b = [cast(void*)2];
+ auto c = a ~ b;
+ assert(c == [cast(void*)1, cast(void*)2]);
+}
+
+/***************************************************/
+
int main()
{
test1();
@@ -5715,6 +5725,7 @@ int main()
test8376();
test8796();
test9171();
+ test9248();
writefln("Success");
return 0;
Please sign in to comment.
Something went wrong with that request. Please try again.