Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@donc donc authored
Showing with 16 additions and 0 deletions.
  1. +3 −0  src/cast.c
  2. +13 −0 test/runnable/xtest46.d
View
3  src/cast.c
@@ -554,6 +554,9 @@ MATCH ArrayLiteralExp::implicitConvTo(Type *t)
result = MATCHnomatch;
}
+ if (!elements->dim && typeb->nextOf()->toBasetype()->ty != Tvoid)
+ result = MATCHnomatch;
+
Type *telement = tb->nextOf();
for (size_t i = 0; i < elements->dim; i++)
{ Expression *e = (*elements)[i];
View
13 test/runnable/xtest46.d
@@ -831,6 +831,18 @@ void test44()
/***************************************************/
+void test2006()
+{
+ string [][] aas = [];
+ assert(aas.length == 0);
+ aas ~= cast (string []) [];
+ assert(aas.length == 1);
+ aas = aas ~ cast (string []) [];
+ assert(aas.length == 2);
+}
+
+/***************************************************/
+
class A45
{
int x;
@@ -5240,6 +5252,7 @@ int main()
test3559();
test84();
test85();
+ test2006();
test86();
test87();
test5554();
Please sign in to comment.
Something went wrong with that request. Please try again.