Add support for class members
Fix #2723
Add support for class members by identifying them by the new intent ClassMember and creating a global variable for each class member.
All the tests are not passing yet, but I need a review to know if I'm going in the right direction.
The tests are now passing.
I now need to implement functionality for when an instance variable accesses a class member. If it performs a read, it should access the global variable. But, if it writes to the class member, a copy should be made for that specific instance and used for any further reads and writes.
Currently, instance variables only access the global class member.
class A:
c: i32 = 10
def __init__(self:"A") -> None:
self.d: i32 = 20
a: A = A()
a.c = 30 # Makes a copy
print(a.c) # 30
print(A.c) # Should be 10, it is currently 30
I wanted advice on how to implement this and also if the current design of using global variables for class members is good or not.
One way can be adding the class members definitions to __init__'s body. But then we need to keep track if a copy has been created or not.
@xaerru they fixed CI's it should pass if u rebase