dlang-community / D-Scanner

Swiss-army knife for D source code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warn when not accessing member variable through `this`

cwinter158 opened this issue · comments

What are thoughts on issuing a warning when accessing a member variable without going through the this reference?

struct A {
    int i;

    this(int i)
    {
        i = i; // <-- Warning
        this.i = i; // <-- Ok
    }
}

My request is motivated by the specific issue highlighted in this example, but this check in general would remove some ambiguities, especially in constructors (I don't know easy it would be to limit the check to constructors, though).

It would surely be extremely noisy for most projects, so maybe would make most sense to be disabled by default.