Skip to content

Commit

Permalink
Merge pull request #3912 from yebblies/issue3990
Browse files Browse the repository at this point in the history
Issue 3990 - Deferencing a dynamic array as pointer
  • Loading branch information
9rnsr committed Aug 31, 2014
2 parents cdd82c3 + 5bbacc5 commit 6adcefd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/expression.c
Expand Up @@ -9185,7 +9185,7 @@ Expression *PtrExp::semantic(Scope *sc)

case Tsarray:
case Tarray:
deprecation("using * on an array is deprecated; use *(%s).ptr instead", e1->toChars());
error("using * on an array is no longer supported; use *(%s).ptr instead", e1->toChars());
type = ((TypeArray *)tb)->next;
e1 = e1->castTo(sc, type->pointerTo());
break;
Expand Down
15 changes: 15 additions & 0 deletions test/fail_compilation/fail3990.d
@@ -0,0 +1,15 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail3990.d(12): Error: using * on an array is no longer supported; use *(arr1).ptr instead
fail_compilation/fail3990.d(14): Error: using * on an array is no longer supported; use *(arr2).ptr instead
---
*/

void main()
{
int[] arr1 = [1, 2, 3];
assert(*arr1 == 1);
int[3] arr2 = [1, 2, 3];
assert(*arr2 == 1);
}
17 changes: 0 additions & 17 deletions test/runnable/deprecate1.d
Expand Up @@ -1224,22 +1224,6 @@ void test4237()
foo4237(); bar4237();
}

/******************************************/
// 3990

void test3990()
{
int[] a1 = [5, 4, 3];
assert(*a1 == 5);
alias typeof(a1) T1;
assert(is(typeof(*T1)));

int[3] a2 = [5, 4, 3];
assert(*a2 == 5);
alias typeof(a2) T2;
assert(is(typeof(*T2)));
}

/******************************************/
// from extra-files/test2.d

Expand Down Expand Up @@ -1311,7 +1295,6 @@ int main()
test23_test67();
test34_test14();
test34_test52();
test3990();
test6289();
test4237();
test18();
Expand Down

0 comments on commit 6adcefd

Please sign in to comment.