blueloveTH 1 rok temu
rodzic
commit
9c173fdada
2 zmienionych plików z 7 dodań i 3 usunięć
  1. 1 1
      src/interpreter/vm.c
  2. 6 2
      tests/41_class_ex.py

+ 1 - 1
src/interpreter/vm.c

@@ -202,7 +202,7 @@ void VM__dtor(VM* self) {
     // destroy all objects
     ManagedHeap__dtor(&self->heap);
     // clear frames
-    // ...
+    while(self->top_frame) VM__pop_frame(self);
     NameDict__dtor(&self->modules);
     c11__foreach(py_TypeInfo, &self->types, ti) py_TypeInfo__dtor(ti);
     c11_vector__dtor(&self->types);

+ 6 - 2
tests/41_class_ex.py

@@ -1,7 +1,11 @@
 class A:
-    def __init__(self, a, b):
+    def __init__(self, a, __b):
         self.a = a
-        self.b = b
+        self.__b = __b
+
+    @property
+    def b(self):
+        return self.__b
 
     def add(self):
         return self.a + self.b