Explorar o código

add special case for abstract `this` variable when dealing with OpAssignOps (closes #3067)

Simon Krajewski %!s(int64=11) %!d(string=hai) anos
pai
achega
e51ff7b7fd
Modificáronse 2 ficheiros con 29 adicións e 1 borrados
  1. 28 0
      tests/unit/unitstd/Issue3067.hx
  2. 1 1
      typer.ml

+ 28 - 0
tests/unit/unitstd/Issue3067.hx

@@ -0,0 +1,28 @@
+package unit.unitstd;
+
+private abstract TestAbstract(Int) from Int to Int
+{
+    public var property(get, set):Int;
+
+    function get_property():Int
+    {
+        return 5;
+    }
+
+    function set_property(i:Int):Int
+    {
+        return i;
+    }
+
+	function manipulateProperty():Void
+	{
+		property *= 1;
+	}
+}
+
+class Issue3067 extends Test {
+	function test() {
+		var a:TestAbstract = 1;
+		eq(5, a.property);
+	}
+}

+ 1 - 1
typer.ml

@@ -1773,7 +1773,7 @@ let rec type_binop ctx op e1 e2 is_assign_op with_type p =
 			in
 			let l = save_locals ctx in
 			let v,is_temp = match et.eexpr with
-				| TLocal v -> v,false
+				| TLocal v when not (v.v_name = "this") -> v,false
 				| _ -> gen_local ctx ta,true
 			in
 			let ev = mk (TLocal v) ta p in