diff --git a/extra/CHANGES.txt b/extra/CHANGES.txt index d3580801b0d..fae8c4cfe2f 100644 --- a/extra/CHANGES.txt +++ b/extra/CHANGES.txt @@ -3,6 +3,8 @@ Bugfixes: all : fixed issue with side-effect detection when optimizing (#5911) + php7 : Allow user-defined modules in `php` package (#5921) + php7 : Dereference some of `php.Syntax` methods if required (#5923) 2016-12-24: 3.4.0-RC2 diff --git a/src/generators/genphp7.ml b/src/generators/genphp7.ml index eb69c24a28d..7eabf3d17bc 100644 --- a/src/generators/genphp7.ml +++ b/src/generators/genphp7.ml @@ -364,6 +364,12 @@ let needs_dereferencing expr = | TArrayDecl _ -> true | TObjectDecl _ -> true | TConst TNull -> true + (* some of `php.Syntax` methods *) + | TCall ({ eexpr = TField (_, FStatic ({ cl_path = syntax_type_path }, { cf_name = name })) }, _) -> + (match name with + | "binop" | "object" | "array" -> true + | _ -> false + ) | _ -> false in match expr.eexpr with diff --git a/tests/unit/src/unit/issues/Issue5923.hx b/tests/unit/src/unit/issues/Issue5923.hx new file mode 100644 index 00000000000..1b375177253 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue5923.hx @@ -0,0 +1,18 @@ +package unit.issues; + +#if php7 +import php.Syntax.*; +#end + +class Issue5923 extends unit.Test { +#if php7 + function test() { + //These expressions should not fail at runtime + binop({}, '??', null).value = 1; + object(arrayDecl()).value = 1; + array({})['value'] = 1; + + t(true); + } +#end +} \ No newline at end of file