d: Merge upstream dmd 47871363d, druntime, c52e28b7, phobos 99e9c1b77.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / diag14145.d
blob6447f5e59962c577815ce13bb171e7d8c21a8948
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/diag14145.d(15): Error: no property `i` for type `diag14145.main.Capture!(i)`
5 fail_compilation/diag14145.d(15): potentially malformed `opDispatch`. Use an explicit instantiation to get a better error message
6 fail_compilation/diag14145.d(34): Error: expression `*this.ptr` of type `shared(int)` is not implicitly convertible to return type `ref int`
7 fail_compilation/diag14145.d(16): Error: template instance `diag14145.main.Capture!(i).Capture.opDispatch!"i"` error instantiating
8 ---
9 */
11 int main()
13 int i;
14 auto _ = capture!i;
15 _.i;
16 _.opDispatch!"i";
17 return 0;
20 auto capture(alias c)()
22 return Capture!c(c);
25 struct Capture(alias c)
27 shared typeof(c)* ptr;
28 this(ref typeof(c) _c)
30 ptr = cast(shared)&c;
32 ref shared typeof(c) opDispatch(string s)()
34 return *ptr;