| 1 |
/** |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/named_arguments_overload.d(33): Error: none of the overloads of `snoopy` are callable using argument types `(immutable(S), immutable(T))` |
| 5 |
fail_compilation/named_arguments_overload.d(17): Candidates are: `named_arguments_overload.snoopy(S s, int i = 0, T t = T())` |
| 6 |
fail_compilation/named_arguments_overload.d(18): `named_arguments_overload.snoopy(T t, int i, S s)` |
| 7 |
fail_compilation/named_arguments_overload.d(34): Error: none of the overloads of `snoopy` are callable using argument types `(immutable(T), immutable(S))` |
| 8 |
fail_compilation/named_arguments_overload.d(17): Candidates are: `named_arguments_overload.snoopy(S s, int i = 0, T t = T())` |
| 9 |
fail_compilation/named_arguments_overload.d(18): `named_arguments_overload.snoopy(T t, int i, S s)` |
| 10 |
fail_compilation/named_arguments_overload.d(35): Error: `named_arguments_overload.snoopy` called with argument types `(immutable(S), immutable(T), immutable(int))` matches multiple overloads after qualifier conversion: |
| 11 |
fail_compilation/named_arguments_overload.d(17): `named_arguments_overload.snoopy(S s, int i = 0, T t = T())` |
| 12 |
and: |
| 13 |
fail_compilation/named_arguments_overload.d(18): `named_arguments_overload.snoopy(T t, int i, S s)` |
| 14 |
--- |
| 15 |
*/ |
| 16 |
|
| 17 |
char snoopy(S s, int i = 0, T t = T.init) { return 'B'; } |
| 18 |
char snoopy(T t, int i, S s) { return 'A'; } |
| 19 |
|
| 20 |
struct S { } |
| 21 |
struct T { } |
| 22 |
immutable S s = S.init; |
| 23 |
immutable T t = T.init; |
| 24 |
immutable int i = 0; |
| 25 |
|
| 26 |
static assert(snoopy(t, i, s ) == 'A'); |
| 27 |
static assert(snoopy(s, i, t ) == 'B'); |
| 28 |
static assert(snoopy(s:s, t:t ) == 'B'); |
| 29 |
static assert(snoopy(t:t, s:s ) == 'B'); |
| 30 |
static assert(snoopy(t:t, i, s:s) == 'A'); |
| 31 |
static assert(snoopy(s:s, t:t, i ) == 'A'); |
| 32 |
|
| 33 |
immutable err0 = snoopy(s, t); // error, neither A nor B match |
| 34 |
immutable err1 = snoopy(t, s); // error, neither A nor B match |
| 35 |
immutable err2 = snoopy(s:s, t:t, i:i); // error, ambiguous |