@@ -20,6 +20,8 @@ $(COMMENT
20
20
$(TROW `alias` target first syntax, use `alias name = target` instead.)
21
21
$(TROW Struct/union postblit, use a $(DDSUBLINK spec/struct, struct-copy-constructor,
22
22
copy constructor) instead.)
23
+ $(TROW $(RELATIVE_LINK2 alias-instance-member, Aliasing an instance member),
24
+ use `typeof(instance).member` instead.)
23
25
)
24
26
25
27
$(H2 $(LNAME2 body, `body` keyword))
@@ -54,6 +56,36 @@ $(H3 Corrective Action)
54
56
(e.g. javascript) or auto-generating code.
55
57
)
56
58
59
+ $(H2 $(LNAME2 alias-instance-member, Aliasing an instance member))
60
+
61
+ $(P E.g. `alias a = instance.field;`.
62
+ Such an alias actually aliases a member of the instance's *type*, not
63
+ the instance member itself. That could be confusing.
64
+ Instead, alias a member of the type.)
65
+
66
+ $(NOTE Aliasing `this.member` and `super.member` are valid inside
67
+ methods.)
68
+
69
+ ---
70
+ struct Bar
71
+ {
72
+ Foo f;
73
+ alias v = f.v; // Error, use `typeof(f).v`
74
+ }
75
+
76
+ struct Foo
77
+ {
78
+ int v;
79
+ void test(Foo that) const
80
+ {
81
+ alias a = this.v; // OK
82
+ alias b = that.v; // Error, use `typeof(that).v` instead
83
+ assert(&a is &b); // passes
84
+ assert(&b !is &that.v);
85
+ }
86
+ }
87
+ ---
88
+
57
89
58
90
$(SPEC_SUBNAV_PREV glossary, Glossary)
59
91
)
0 commit comments