Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 3990 - Deferencing a dynamic array as pointer #3912

Merged
merged 1 commit into from Aug 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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