| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/fail7352.d(42): Error: template instance `Type!(1)` does not match template declaration `Type(T)` |
| 5 |
fail_compilation/fail7352.d(43): Error: template instance `Type!(b)` does not match template declaration `Type(T)` |
| 6 |
fail_compilation/fail7352.d(43): `b` is not a type |
| 7 |
fail_compilation/fail7352.d(44): Error: template instance `Type!(function () pure nothrow @nogc @safe => 1)` does not match template declaration `Type(T)` |
| 8 |
fail_compilation/fail7352.d(45): Error: template instance `Type!(fun)` does not match template declaration `Type(T)` |
| 9 |
fail_compilation/fail7352.d(45): `fun` is not a type |
| 10 |
fail_compilation/fail7352.d(47): Error: template instance `Immutable!int` does not match template declaration `Immutable(T : immutable(T))` |
| 11 |
fail_compilation/fail7352.d(49): Error: template instance `Value!int` does not match template declaration `Value(string s)` |
| 12 |
fail_compilation/fail7352.d(50): Error: template instance `Value!(1)` does not match template declaration `Value(string s)` |
| 13 |
fail_compilation/fail7352.d(51): Error: template instance `Value!(fun)` does not match template declaration `Value(string s)` |
| 14 |
fail_compilation/fail7352.d(51): `fun` is not of a value of type `string` |
| 15 |
--- |
| 16 |
*/ |
| 17 |
|
| 18 |
template Type(T) |
| 19 |
{ |
| 20 |
} |
| 21 |
|
| 22 |
template Immutable(T : immutable(T)) |
| 23 |
{ |
| 24 |
alias Immutable = T; |
| 25 |
} |
| 26 |
|
| 27 |
template Value(string s) |
| 28 |
{ |
| 29 |
auto x = s; |
| 30 |
} |
| 31 |
|
| 32 |
int fun(int i) |
| 33 |
{ |
| 34 |
return i; |
| 35 |
} |
| 36 |
|
| 37 |
void main() |
| 38 |
{ |
| 39 |
enum a = 1; |
| 40 |
int b; |
| 41 |
|
| 42 |
Type!a testTypeValue; |
| 43 |
Type!b testTypeVar; |
| 44 |
Type!(() => 1) testTypeFuncLiteral; |
| 45 |
Type!fun testTypeFunc; |
| 46 |
|
| 47 |
Immutable!int testImmutable; |
| 48 |
|
| 49 |
auto testValueType = Value!int.x; |
| 50 |
auto testValueWrongType = Value!a.x; |
| 51 |
auto testValueFunc = Value!fun.x; |
| 52 |
} |