Преглед на файлове

[php] do not ignore dynamic methods while generating a constructor in release mode (fixes #4723)

Alexander Kuzmenko преди 8 години
родител
ревизия
590bc2ea7b
променени са 5 файла, в които са добавени 18 реда и са изтрити 2 реда
  1. 1 0
      extra/CHANGES.txt
  2. 3 1
      src/generators/genphp.ml
  3. 2 1
      tests/misc/.gitignore
  4. 9 0
      tests/misc/projects/Issue4723/Test.hx
  5. 3 0
      tests/misc/projects/Issue4723/compile.hxml

+ 1 - 0
extra/CHANGES.txt

@@ -11,6 +11,7 @@
 	php7 : Allow user-defined modules in `php` package (#5921)
 	php7 : Dereference some of `php.Syntax` methods if required (#5923)
 	php : fixed assigning a method of dynamic value to a variable (#5469)
+	php : fixed missing initialization of dynamic methods in classes with empty constructors (#4723)
 
 2016-12-24: 3.4.0-RC2
 

+ 3 - 1
src/generators/genphp.ml

@@ -1338,7 +1338,9 @@ and gen_expr ctx e =
 		if ctx.in_loop then spr ctx "break" else print ctx "break %d" ctx.nested_loops
 	| TContinue ->
 		if ctx.in_loop then spr ctx "continue" else print ctx "continue %d" ctx.nested_loops
-	| TBlock [] ->
+	| TBlock [] when List.length ctx.dynamic_methods = 0 ->
+		let type_name = match ctx.curclass.cl_path with (_, type_name) -> type_name in
+		print_endline (type_name ^ "::" ^ ctx.curmethod ^ " empty block");
 		spr ctx "{}"
 	| TBlock el ->
 		let old_l = ctx.inv_locals in

+ 2 - 1
tests/misc/.gitignore

@@ -1 +1,2 @@
-pypy3-2.4.0*
+pypy3-2.4.0*
+bin

+ 9 - 0
tests/misc/projects/Issue4723/Test.hx

@@ -0,0 +1,9 @@
+class Test {
+	function new() {}
+
+	dynamic function test() {}
+
+	static function main() {
+		new Test().test();
+	}
+}

+ 3 - 0
tests/misc/projects/Issue4723/compile.hxml

@@ -0,0 +1,3 @@
+-main Test
+-php bin
+-cmd php bin/index.php