Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/diag14145.d(14): Error: no property `i` for `_` of type `diag14145.main.Capture!(i)`
5 fail_compilation/diag14145.d(33): Error: expression `*this.ptr` of type `shared(int)` is not implicitly convertible to return type `ref int`
6 fail_compilation/diag14145.d(14): Error: template instance `diag14145.main.Capture!(i).Capture.opDispatch!"i"` error instantiating
7 ---
8 */
9
10 int main()
11 {
12 int i;
13 auto _ = capture!i;
14 _.i;
15 _.opDispatch!"i";
16 return 0;
17 }
18
19 auto capture(alias c)()
20 {
21 return Capture!c(c);
22 }
23
24 struct Capture(alias c)
25 {
26 shared typeof(c)* ptr;
27 this(ref typeof(c) _c)
28 {
29 ptr = cast(shared)&c;
30 }
31 ref shared typeof(c) opDispatch(string s)()
32 {
33 return *ptr;
34 }
35 }