dmd/changelog/dmd.alias-instance-member.dd
Nick Treleaven 56a0ea80b1
Fix Bugzilla 14128 - AliasDeclaration allows expressions, causing false … (#15863)
* Fix Issue 14128 - AliasDeclaration allows expressions, causing false code for ThisExp

* Add test case

* Fix deprecation comment

* Add changelog

* Use dummy out param, not null

* Change to error with __edition_latest_do_not_use
2024-04-19 17:55:31 +03:00

25 lines
568 B
Text

[next edition] Aliasing a member of a type *instance* is now an error
Such an alias actually aliases a member of the instance's *type*, not
the instance member itself. That could be confusing, and is now an error.
Instead, alias a member of the type:
---
struct Foo
{
int v;
void test(Foo that) const
{
alias a = this.v; // OK
alias b = that.v; // Error, use `typeof(that).v` instead
assert(&a is &b); // passes
assert(&b !is &that.v);
}
}
struct Bar
{
Foo f;
alias v = f.v; // Error, use `typeof(f).v`
}
---