Skip to content

Warn when not accessing member variable through this #942

@cwinter158

Description

@cwinter158

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions