After some refactoring I had a series of bugs that came from renaming class members so that the following situation was present.

class foo
{
  float a;

  void doSomething()
  {
    float a;
    a = a * 2.0;
  }
}

The local variable a shadows the member a after the refactoring and therefore this code will no longer work as expected. This was quite time consuming to track down. So I wanted to ask if we want to prevent that with a warning or even an error? D does not allow shadowing of local variables, so why is it allowed for members?

Kind Regards
Benjamin Thaut

Reply via email to