浏览代码

print ; for non EBlock method expressions (closes #3205)

Simon Krajewski 11 年之前
父节点
当前提交
1437afad7e
共有 2 个文件被更改,包括 20 次插入1 次删除
  1. 3 1
      std/haxe/macro/Printer.hx
  2. 17 0
      tests/unit/issues/Issue3205.hx

+ 3 - 1
std/haxe/macro/Printer.hx

@@ -270,7 +270,9 @@ class Printer {
 						var fstr = printField(f);
 						tabs + fstr + switch(f.kind) {
 							case FVar(_, _), FProp(_, _, _, _): ";";
-							case FFun(func) if (func.expr == null): ";";
+							case FFun({expr:null}): ";";
+							case FFun({expr:{expr:EBlock(_)}}): "";
+							case FFun(_): ";";
 							case _: "";
 						};
 					}].join("\n")

+ 17 - 0
tests/unit/issues/Issue3205.hx

@@ -0,0 +1,17 @@
+package unit.issues;
+
+class Issue3205 extends Test {
+	function test() {
+		var td = macro class X {
+			public function test1() return 1;
+			public function test2() {
+				return 1;
+			}
+			function test3();
+		}
+		var printer = new haxe.macro.Printer();
+		var s = printer.printTypeDefinition(td);
+		s = ~/[\t\n\r]/g.replace(s, "");
+		eq("class X {public function test1() return 1;public function test2() {return 1;}function test3();}", s);
+	}
+}