Browse Source

[php7] handle integer literal -2147483648 as a special case to workaround a php bug on 32bit systems (fixes #5289)

Alexander Kuzmenko 8 years ago
parent
commit
ac27f7a277
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/generators/genphp7.ml

+ 6 - 1
src/generators/genphp7.ml

@@ -1697,13 +1697,18 @@ class virtual type_builder ctx wrapper =
 		*)
 		method private write_expr_const const =
 			match const with
-				| TInt value -> self#write (Int32.to_string value)
 				| TFloat str -> self#write str
 				| TString str -> self#write ("\"" ^ (escape_bin str) ^ "\"")
 				| TBool value -> self#write (if value then "true" else "false")
 				| TNull -> self#write "null"
 				| TThis -> self#write "$this"
 				| TSuper -> self#write "parent"
+				| TInt value ->
+					(* See https://github.com/HaxeFoundation/haxe/issues/5289 *)
+					if (Int32.to_int value) = -2147483648 then
+						self#write "((int)-2147483648)"
+					else
+						self#write (Int32.to_string value)
 		(**
 			Writes TArrayDecl to output buffer
 		*)