Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/bug9631.d

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/bug9631.d(20): Error: cannot implicitly convert expression `F()` of type `bug9631.T1!().F` to `bug9631.T2!().F`
5 ---
6 */
7
8 template T1()
9 {
10 struct F { }
11 }
12
13 template T2()
14 {
15 struct F { }
16 }
17
18 void main()
19 {
20 T2!().F x = T1!().F();
21 }
22 /*
23 TEST_OUTPUT:
24 ---
25 fail_compilation/bug9631.d(41): Error: no operator `==` for type `S`
26 fail_compilation/bug9631.d(30): perhaps overload it with `bool opEquals(S other) const {}`
27 ---
28 */
29
30 struct S { char c; }
31
32 template tem()
33 {
34 struct S { int i; }
35 }
36
37 void equal()
38 {
39 S x;
40 auto y = tem!().S();
41 bool b = x == y;
42 }
43
44 /*
45 TEST_OUTPUT:
46 ---
47 fail_compilation/bug9631.d(55): Error: cannot cast expression `x` of type `bug9631.S` to `bug9631.tem!().S` because of different sizes
48 fail_compilation/bug9631.d(58): Error: cannot cast expression `ta` of type `bug9631.tem!().S[1]` to `bug9631.S[1]` because of different sizes
49 fail_compilation/bug9631.d(59): Error: cannot cast expression `sa` of type `S[1]` to `S[]` since sizes don't line up
50 ---
51 */
52 void test3()
53 {
54 S x;
55 auto y = cast(tem!().S)x;
56
57 tem!().S[1] ta;
58 S[1] sa = cast(S[1])ta;
59 auto t2 = cast(tem!().S[])sa;
60 }
61
62 /*
63 TEST_OUTPUT:
64 ---
65 fail_compilation/bug9631.d(80): Error: function `f` is not callable using argument types `(int, S)`
66 fail_compilation/bug9631.d(80): cannot pass argument `y` of type `bug9631.tem!().S` to parameter `bug9631.S s`
67 fail_compilation/bug9631.d(79): `bug9631.arg.f(int i, S s)` declared here
68 fail_compilation/bug9631.d(81): Error: function literal `(S s) { }` is not callable using argument types `(S)`
69 fail_compilation/bug9631.d(81): cannot pass argument `x` of type `bug9631.S` to parameter `bug9631.tem!().S s`
70 fail_compilation/bug9631.d(87): Error: constructor `bug9631.arg.A.this(S __param_0)` is not callable using argument types `(S)`
71 fail_compilation/bug9631.d(87): cannot pass argument `S(0)` of type `bug9631.tem!().S` to parameter `bug9631.S __param_0`
72 ---
73 */
74 void arg()
75 {
76 S x;
77 tem!().S y;
78
79 void f(int i, S s);
80 f(4, y);
81 (tem!().S s){}(x);
82
83 struct A
84 {
85 this(S){}
86 }
87 A(tem!().S());
88 }
89
90 /*
91 TEST_OUTPUT:
92 ---
93 fail_compilation/bug9631.d(108): Error: function `ft` is not callable using argument types `(S)`
94 fail_compilation/bug9631.d(108): cannot pass argument `x` of type `bug9631.S` to parameter `bug9631.tem!().S __param_0`
95 fail_compilation/bug9631.d(107): `bug9631.targ.ft!().ft(S __param_0)` declared here
96 fail_compilation/bug9631.d(109): Error: template `ft` is not callable using argument types `!()(S)`
97 fail_compilation/bug9631.d(107): Candidate is: `ft()(tem!().S)`
98 fail_compilation/bug9631.d(111): Error: template `ft2` is not callable using argument types `!()(S, int)`
99 fail_compilation/bug9631.d(110): Candidate is: `ft2(T)(S, T)`
100 ---
101 */
102 void targ()
103 {
104 S x;
105 tem!().S y;
106
107 void ft()(tem!().S){}
108 ft!()(x);
109 ft(x);
110 void ft2(T)(S, T){}
111 ft2(y, 1);
112 }