The checker does not check whether we are accessing unassigned class variables within class constructors.
How to Reproduce
The following does not give any type errors:
class X
def z: Int
def init(self, x: Int) =>
self.z += 10
This is because within the check stage, this is converted to self.z = self.z + 10, which is simply treated as an assign.
Expected behavior
It should mention that we cannot use the variable because it is not assigned.
More generally, the checker should error if a variable which has not been assigned to is used anywhere.
Then self.z = self.z + 10 would also error because we are accessing self.z.
Outside the constructor all class variables should be assigned to (see #300 ).
The only real issue is when we are inside the constructor.
Description of Bug
The checker does not check whether we are accessing unassigned class variables within class constructors.
How to Reproduce
The following does not give any type errors:
This is because within the check stage, this is converted to
self.z = self.z + 10
, which is simply treated as an assign.Expected behavior
It should mention that we cannot use the variable because it is not assigned.
More generally, the checker should error if a variable which has not been assigned to is used anywhere. Then
self.z = self.z + 10
would also error because we are accessingself.z
.Outside the constructor all class variables should be assigned to (see #300 ). The only real issue is when we are inside the constructor.