Debian Codegraph @

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

raw
1 // https://issues.dlang.org/show_bug.cgi?id=21674
2 // REQUIRED_ARGS: -de
3
4 struct Module
5 {
6 CachedString data;
7 }
8
9 struct CachedString
10 {
11 private size_t len;
12
13 this (string data) { this.len = data.length; }
14 public string str () const { return null; }
15 public void str (string value) { this.len = value.length; }
16
17 alias str this;
18 }
19
20 void test21674a()
21 {
22 Module m;
23 m.data = "Hello World";
24 }
25
26 //////////////////////////////////////////
27
28 struct StaticGetter(T)
29 {
30 private static T _impl;
31 static ref T value() { return _impl; }
32 alias value this;
33 }
34
35 struct StaticWrapper
36 {
37 StaticGetter!int get;
38 alias get this;
39 }
40
41 void test21674b()
42 {
43 StaticGetter!float sg;
44 sg = 4.2;
45
46 StaticWrapper sw;
47 sw = 42;
48 }
49
50 //////////////////////////////////////////
51
52 EntryType arr;
53 auto getPtr() { return &arr; }
54
55 struct EntryType
56 {
57 bool _state;
58 alias _state this;
59 }
60
61 struct S19441
62 {
63 @property auto ref entry() { return *getPtr(); }
64 alias entry this;
65 }
66
67 void test19441()
68 {
69 S19441 s19441;
70 s19441 = true;
71 }