Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #691 from yebblies/issue2006

Issue 2006 - Empty array literals with explicit type implicitly convert to any array type
  • Loading branch information...
commit 9268d6fb1bedf9d931eadb5adf4067698b0d1e19 2 parents 52d48df + 82700b3
Don Clugston authored July 19, 2012
3  src/cast.c
@@ -554,6 +554,9 @@ MATCH ArrayLiteralExp::implicitConvTo(Type *t)
554 554
                 result = MATCHnomatch;
555 555
         }
556 556
 
  557
+        if (!elements->dim && typeb->nextOf()->toBasetype()->ty != Tvoid)
  558
+            result = MATCHnomatch;
  559
+
557 560
         Type *telement = tb->nextOf();
558 561
         for (size_t i = 0; i < elements->dim; i++)
559 562
         {   Expression *e = (*elements)[i];
13  test/runnable/xtest46.d
@@ -831,6 +831,18 @@ void test44()
831 831
 
832 832
 /***************************************************/
833 833
 
  834
+void test2006()
  835
+{
  836
+    string [][] aas = [];
  837
+    assert(aas.length == 0);
  838
+    aas ~= cast (string []) [];
  839
+    assert(aas.length == 1);
  840
+    aas = aas ~ cast (string []) [];
  841
+    assert(aas.length == 2);
  842
+}
  843
+
  844
+/***************************************************/
  845
+
834 846
 class A45
835 847
 {
836 848
   int x;
@@ -5240,6 +5252,7 @@ int main()
5240 5252
     test3559();
5241 5253
     test84();
5242 5254
     test85();
  5255
+    test2006();
5243 5256
     test86();
5244 5257
     test87();
5245 5258
     test5554();

0 notes on commit 9268d6f

Please sign in to comment.
Something went wrong with that request. Please try again.