6da5b02a8e28 — Leonard Ritter 16 days ago
* fixed inplace operators failing on properties
2 files changed, 21 insertions(+), 18 deletions(-)

M lib/scopes/property.sc
M testing/test_property.sc
M lib/scopes/property.sc +2 -2
@@ 23,7 23,7 @@ inline property (getter setter)
                 unqualified (returnof (typeof F))
 
             inline get (self)
-                getter (bitcast self T)
+                getter (bitcast (view self) T)
 
             inline __imply (cls destT)
                 static-if (destT == immutable) get

          
@@ 51,7 51,7 @@ inline property (getter setter)
 
             inline __= (cls destT)
                 inline (self value)
-                    setter (bitcast self T) value
+                    setter (bitcast (view self) T) value
 
     Accessor
         inline "generate-property" (value key)

          
M testing/test_property.sc +19 -16
@@ 4,25 4,28 @@ using import testing
 using import struct
 using import property
 
-struct IntOrFloat
-    float : f32
+do
+    struct IntOrFloat plain
+        float : f32
 
-    int :=
-        property
-            inline "getter" (self)
-                self.float as i32
-            inline "setter" (self value)
-                self.float = value as f32
+        int :=
+            property
+                inline "getter" (self)
+                    self.float as i32
+                inline "setter" (self value)
+                    self.float = value as f32
 
-local iof = (IntOrFloat 3.0)
+    local iof = (IntOrFloat 3.0)
 
-print iof.float
-print iof.int
-test (iof.float == 3.0)
-test (iof.int == 3)
-iof.int = 11
-test (iof.float == 11.0)
-test (iof.int == 11)
+    print iof.float
+    print iof.int
+    test (iof.float == 3.0)
+    test (iof.int == 3)
+    iof.int = 11
+    test (iof.float == 11.0)
+    test (iof.int == 11)
+    iof.int += 1
+    test (iof.int == 12)
 
 ;