Kaynağa Gözat

reverse inline arguments so they have left-to-right order (closes issue #2627)

Simon Krajewski 11 yıl önce
ebeveyn
işleme
5e9a9cd020
2 değiştirilmiş dosya ile 25 ekleme ve 0 silme
  1. 1 0
      optimizer.ml
  2. 24 0
      tests/unit/issues/Issue2627.hx

+ 1 - 0
optimizer.ml

@@ -245,6 +245,7 @@ let rec type_inline ctx cf f ethis params tret config p ?(self_calling_closure=f
 		if has_side_effect e then l.i_force_temp <- true; (* force tmp var *)
 		if has_side_effect e then l.i_force_temp <- true; (* force tmp var *)
 		l, e
 		l, e
 	) (ethis :: loop params f.tf_args true) ((vthis,None) :: f.tf_args) in
 	) (ethis :: loop params f.tf_args true) ((vthis,None) :: f.tf_args) in
+	let inlined_vars = List.rev inlined_vars in
 	(*
 	(*
 		here, we try to eliminate final returns from the expression tree.
 		here, we try to eliminate final returns from the expression tree.
 		However, this is not entirely correct since we don't yet correctly propagate
 		However, this is not entirely correct since we don't yet correctly propagate

+ 24 - 0
tests/unit/issues/Issue2627.hx

@@ -0,0 +1,24 @@
+package unit.issues;
+
+class Issue2627 extends unit.Test {
+	
+	var field:Int;
+	
+    function test1() {
+        var c = 0;
+        var s = staticAdd(c++, c++);
+		eq(s, -1);
+		eq(c, 2);
+    }
+	
+	function test2() {
+		field = 0;
+		var s = memberAdd(field++, field++);
+		eq(s, 1);
+		eq(field, 2);
+	}
+
+	inline static function staticAdd(x:Float, y:Float) { return x - y; }
+	
+	inline function memberAdd(x:Float, y:Float) { return this.field - x - y; }
+}