Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail117.d(35): Error: expression `foo.mixin MGettor!(a) geta;` is `void` and has no value
5 fail_compilation/fail117.d(36): Error: expression `foo.mixin MGettor!(b) getb;` is `void` and has no value
6 ---
7 */
8
9 // https://issues.dlang.org/show_bug.cgi?id=420
10 // mixin make dmd break
11 //import std.stdio;
12
13 template MGettor(alias Fld)
14 {
15 typeof(Fld) opCall()
16 {
17 //writefln("getter");
18 return Fld;
19 }
20 }
21
22 class Foo
23 {
24 int a = 1,
25 b = 2;
26
27 mixin MGettor!(a) geta;
28 mixin MGettor!(b) getb;
29 }
30
31 void main()
32 {
33 auto foo = new Foo;
34
35 int a = foo.geta;
36 int b = foo.getb;
37 }