| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/alias_instance_member.d(18): Error: cannot alias variable member `v` of variable `that` |
| 5 |
fail_compilation/alias_instance_member.d(18): Use `typeof(that)` instead to preserve behaviour |
| 6 |
--- |
| 7 |
*/ |
| 8 |
|
| 9 |
@__edition_latest_do_not_use |
| 10 |
module aim; |
| 11 |
|
| 12 |
struct Foo |
| 13 |
{ |
| 14 |
int v; |
| 15 |
void test(Foo that) const |
| 16 |
{ |
| 17 |
alias a = this.v; // OK |
| 18 |
alias b = that.v; |
| 19 |
assert(&a is &b); |
| 20 |
alias b2 = typeof(that).v; // OK |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
void main() |
| 25 |
{ |
| 26 |
Foo a = Foo(1); |
| 27 |
Foo b = Foo(2); |
| 28 |
a.test(b); |
| 29 |
} |