Disallow initializing fields with themself (#20696)

This commit is contained in:
Dennis 2025-01-20 22:49:24 +01:00 committed by GitHub
parent 2ecfa63ce7
commit 2a627016f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 70 additions and 3 deletions

View 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
}
}
---