2
0
Эх сурвалжийг харах

php: issues with closing brackets (closed #1535)

Franco Ponticelli 12 жил өмнө
parent
commit
d0a9628bee
2 өөрчлөгдсөн 21 нэмэгдсэн , 2 устгасан
  1. 5 2
      genphp.ml
  2. 16 0
      tests/unit/TestPhp.hx

+ 5 - 2
genphp.ml

@@ -401,8 +401,11 @@ let unsupported msg p = error ("This expression cannot be generated to PHP: " ^
 
 let newline ctx =
 	match Buffer.nth ctx.buf (Buffer.length ctx.buf - 1) with
-	| '}' | '{' | ':' | ' ' -> print ctx "\n%s" ctx.tabs
-	| _ -> print ctx ";\n%s" ctx.tabs
+	| '{' | ':' | ' '
+	| '}' when Buffer.nth ctx.buf (Buffer.length ctx.buf - 2) != '"' ->
+		print ctx "\n%s" ctx.tabs
+	| _ ->
+		print ctx ";\n%s" ctx.tabs
 
 let rec concat ctx s f = function
 	| [] -> ()

+ 16 - 0
tests/unit/TestPhp.hx

@@ -2,6 +2,8 @@ package unit;
 
 class TestPhp extends Test
 {
+	var list : Array<Dynamic>;
+	var list2 : Array<Dynamic>;
 	function empty() return true;
 	function testAbstractEnum()
 	{
@@ -12,6 +14,20 @@ class TestPhp extends Test
 	{
 		t(empty());
 	}
+
+	function testList2()
+	{
+		list2 = new Array<Dynamic>();
+		for( l in list2 ) {} // fails here
+		t(true);
+	}
+
+	function testList()
+	{
+		list = new Array<Dynamic>();
+		for( l in list ) {} // fails here
+		t(true);
+	}
 }
 
 enum Annotation {