| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/diag16977.d(25): Error: undefined identifier `undefined`, did you mean function `undefinedId`? |
| 5 |
fail_compilation/diag16977.d(26): Error: cannot implicitly convert expression `"\x01string"` of type `string` to `int` |
| 6 |
fail_compilation/diag16977.d(27): Error: template `templ` is not callable using argument types `!()(int)` |
| 7 |
fail_compilation/diag16977.d(20): Candidate is: `templ(S)(S s)` |
| 8 |
with `S = int` |
| 9 |
must satisfy the following constraint: |
| 10 |
` false` |
| 11 |
fail_compilation/diag16977.d(28): Error: cannot implicitly convert expression `5` of type `int` to `string` |
| 12 |
fail_compilation/diag16977.d(30): Error: template instance `diag16977.test.funcTemplate!string` error instantiating |
| 13 |
--- |
| 14 |
*/ |
| 15 |
|
| 16 |
// when copying the expression of a default argument, location information is |
| 17 |
// replaced by the location of the caller to improve debug information |
| 18 |
// verify error messages are displayed for the original location only |
| 19 |
|
| 20 |
string templ(S)(S s) if(false) { return null; } |
| 21 |
|
| 22 |
void test() |
| 23 |
{ |
| 24 |
// local functions to defer evaluation into semantic3 pass |
| 25 |
void undefinedId(int x, int y = undefined) {} |
| 26 |
void badOp(int x, int y = 1 ~ "string") {} |
| 27 |
void lazyTemplate(int x, lazy int y = 4.templ) {} |
| 28 |
void funcTemplate(T)(T y = 5) {} |
| 29 |
|
| 30 |
funcTemplate!string(); |
| 31 |
undefinedId(1); |
| 32 |
badOp(2); |
| 33 |
lazyTemplate(3); |
| 34 |
} |