mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00

* 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
25 lines
568 B
Text
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`
|
|
}
|
|
---
|