Skip to content

Commit

Permalink
fix Issue 14629 - Type system breaking and wrong code bugs in casting…
Browse files Browse the repository at this point in the history
… reference types to typeof(null)
  • Loading branch information
9rnsr committed May 30, 2015
1 parent 77a7952 commit aefeb3f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/fail_compilation/fail_casting.d
Expand Up @@ -192,3 +192,32 @@ void test14596()
auto arr = cast(char[])p;
char[2] sarr = cast(char[2])p;
}

/*
TEST_OUTPUT:
---
fail_compilation/fail_casting.d(217): Error: cannot cast expression c of type fail_casting.test14629.C to typeof(null)
fail_compilation/fail_casting.d(218): Error: cannot cast expression p of type int* to typeof(null)
fail_compilation/fail_casting.d(219): Error: cannot cast expression da of type int[] to typeof(null)
fail_compilation/fail_casting.d(220): Error: cannot cast expression aa of type int[int] to typeof(null)
fail_compilation/fail_casting.d(221): Error: cannot cast expression fp of type int function() to typeof(null)
fail_compilation/fail_casting.d(222): Error: cannot cast expression dg of type int delegate() to typeof(null)
---
*/
void test14629()
{
alias P = int*; P p;
alias DA = int[]; DA da;
alias AA = int[int]; AA aa;
alias FP = int function(); FP fp;
alias DG = int delegate(); DG dg;
class C {} C c;
alias N = typeof(null);

{ auto x = cast(N)c; }
{ auto x = cast(N)p; }
{ auto x = cast(N)da; }
{ auto x = cast(N)aa; }
{ auto x = cast(N)fp; }
{ auto x = cast(N)dg; }
}

0 comments on commit aefeb3f

Please sign in to comment.