Debian Codegraph @

gcc/testsuite/gdc.test/compilable/testAliasLookup.d

raw
1 // REQUIRED_ARGS: -preview=fixAliasThis
2
3 // https://issues.dlang.org/show_bug.cgi?id=16086
4 struct A
5 {
6 void tail() {}
7 }
8
9 struct S16086
10 {
11 struct Inner2
12 {
13 Inner a;
14 alias a this;
15 }
16
17 struct Inner
18 {
19 int unique_identifier_name;
20 int tail = 2;
21 }
22
23 Inner2 inner;
24 alias inner this;
25
26 auto works()
27 {
28 return unique_identifier_name;
29 }
30
31 auto fails()
32 {
33 int a = tail;
34 return tail; // Line 22
35 // The workaround: return this.tail;
36 }
37 }
38
39 // https://issues.dlang.org/show_bug.cgi?id=16082
40 struct S16082
41 {
42 struct Inner
43 {
44 int any_name_but_modulename;
45 int aliasthis = 5;
46 }
47
48 Inner inner;
49 alias inner this;
50
51 auto works()
52 {
53 return any_name_but_modulename;
54 }
55 auto fails()
56 {
57 return aliasthis; // Line 20
58 }
59 }