d: Merge upstream dmd, druntime 4ca4140e58, phobos 454dff14d.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / named_arguments_overload.d
bloba9704464605c8a6dd9c7e6e284e2f21d359747e6
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 both:
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 ---
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'; }
20 struct S { }
21 struct T { }
22 immutable S s = S.init;
23 immutable T t = T.init;
24 immutable int i = 0;
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');
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