Skip to content

Commit

Permalink
[php7] dereference Syntax.binop(), Syntax.array() and Syntax.object()…
Browse files Browse the repository at this point in the history
… in left part of assignments (fixes #5923)
  • Loading branch information
RealyUniqueName committed Jan 5, 2017
1 parent e3b8bcc commit e2e3550
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions extra/CHANGES.txt
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions src/generators/genphp7.ml
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions 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
}

0 comments on commit e2e3550

Please sign in to comment.