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

[php7] fixed php error on parsing expressions like `a == b == c` (#6720)

Alexander Kuzmenko 7 жил өмнө
parent
commit
662d06c886

+ 1 - 0
extra/CHANGES.txt

@@ -11,6 +11,7 @@
 	php7 : don't fail on generating import aliases for classes with the similar names (#6680)
 	php7 : fixed appending "sqlite:" prefix to the names of files created by `sys.db.Sqlite.open()` (#6692)
 	php7 : made php.Lib.objectOfAssociativeArray() recursive (#6698)
+	php7 : fixed php error on parsing expressions like `a == b == c` (#6720)
 	php/php7 : fixed `sys.net.Socket.bind()` (#6693)
 
 2017-10-08: 3.4.4

+ 1 - 1
src/generators/genphp7.ml

@@ -361,7 +361,7 @@ let parenthesis expr = {eexpr = TParenthesis expr; etype = expr.etype; epos = ex
 	Check if `current` binary should be surrounded with parenthesis
 *)
 let need_parenthesis_for_binop current parent =
-	if current = parent then
+	if current = parent && current != OpNotEq && current != OpEq then
 		false
 	else
 		match (current, parent) with

+ 11 - 0
tests/unit/src/unit/issues/Issue6720.hx

@@ -0,0 +1,11 @@
+package unit.issues;
+
+class Issue6720 extends unit.Test {
+	static var a = 0;
+	static var b = 1;
+
+	function test() {
+		t(a != 0 != (b != 0));
+		f(a == 0 == (b == 0));
+	}
+}