瀏覽代碼

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

Simon Krajewski 11 年之前
父節點
當前提交
5e9a9cd020
共有 2 個文件被更改,包括 25 次插入0 次删除
  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 *)
 		l, e
 	) (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.
 		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; }
+}