From da8e2a038105ad0149a8f66fbcfe31079ce3a534 Mon Sep 17 00:00:00 2001 From: k-hara Date: Sun, 9 Sep 2012 21:08:03 +0900 Subject: [PATCH] fix Issue 8201 - Conversion from dynamic array to static array fails when static array is immutable --- src/expression.c | 5 ++++- test/runnable/testconst.d | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/expression.c b/src/expression.c index 589a41034df5..52aeecd623d6 100644 --- a/src/expression.c +++ b/src/expression.c @@ -10687,7 +10687,10 @@ Expression *AssignExp::semantic(Scope *sc) { checkPostblit(e2->loc, t2->nextOf()); } - e2 = e2->implicitCastTo(sc, e1->type->constOf()); + if (op == TOKconstruct) + e2 = e2->castTo(sc, e1->type->constOf()); + else + e2 = e2->implicitCastTo(sc, e1->type->constOf()); } else { diff --git a/test/runnable/testconst.d b/test/runnable/testconst.d index 0af4a28b6ba5..f229d5ab19e9 100644 --- a/test/runnable/testconst.d +++ b/test/runnable/testconst.d @@ -2717,6 +2717,19 @@ void test8099() } /************************************/ +// 8201 + +void test8201() +{ + uint[2] msa; + immutable uint[2] isa = msa; + + ubyte[] buffer = [0, 1, 2, 3, 4, 5]; + immutable ubyte[4] iArr = buffer[0 .. 4]; +} + +/************************************/ +// 8212 struct S8212 { int x; } @@ -2846,6 +2859,7 @@ int main() test7757(); test8098(); test8099(); + test8201(); test8212(); printf("Success\n");