mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 20:50:41 +03:00
Disallow initializing fields with themself (#20696)
This commit is contained in:
parent
2ecfa63ce7
commit
2a627016f6
5 changed files with 70 additions and 3 deletions
15
changelog/dmd.deprecation-noop-assignment.dd
Normal file
15
changelog/dmd.deprecation-noop-assignment.dd
Normal file
|
@ -0,0 +1,15 @@
|
|||
Initializing a field with itself has been deprecated
|
||||
|
||||
This is to prevent a common mistake when typing a simple constructor, where a parameter name is misspelled:
|
||||
|
||||
---
|
||||
struct S
|
||||
{
|
||||
int field;
|
||||
|
||||
this(int feild)
|
||||
{
|
||||
this.field = field; // equal to this.field = this.field
|
||||
}
|
||||
}
|
||||
---
|
Loading…
Add table
Add a link
Reference in a new issue