From bc1d7875c4722967c75274c543a2855c990984b1 Mon Sep 17 00:00:00 2001 From: Oguz Ulgen Date: Thu, 1 Mar 2018 15:58:08 -0800 Subject: [PATCH] Fix emitting of empty($this) Summary: as per title Reviewed By: vladima Differential Revision: D7106478 fbshipit-source-id: 177039d96a09b1985eac42a30753d9b17a414797 --- hphp/hack/src/hhbc/decl_vars.ml | 2 +- hphp/hack/src/hhbc/emit_expression.ml | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hphp/hack/src/hhbc/decl_vars.ml b/hphp/hack/src/hhbc/decl_vars.ml index fd45d361ff1..ec25b1975a0 100644 --- a/hphp/hack/src/hhbc/decl_vars.ml +++ b/hphp/hack/src/hhbc/decl_vars.ml @@ -154,7 +154,7 @@ class declvar_visitor explicit_use_set_opt is_in_static_method = object(this) | _ -> acc in let call_w_bareparam = match e with - | (_, Ast.Id(_, ("isset" | "echo"))) -> false + | (_, Ast.Id(_, ("isset" | "echo" | "empty"))) -> false | _ -> true in let on_arg acc e = match e with diff --git a/hphp/hack/src/hhbc/emit_expression.ml b/hphp/hack/src/hhbc/emit_expression.ml index 3602e0944c8..c00f2028747 100644 --- a/hphp/hack/src/hhbc/emit_expression.ml +++ b/hphp/hack/src/hhbc/emit_expression.ml @@ -1482,8 +1482,16 @@ and emit_call_empty_expr env outer_pos (pos, expr_ as expr) = Emit_pos.emit_pos outer_pos; instr_emptyg ] - | A.Lvar id when not (is_local_this env (snd id)) -> - instr_emptyl (get_local env id) + | A.Lvar id -> + if not (is_local_this env (snd id)) || + Emit_env.get_needs_local_this env then + instr_emptyl (get_local env id) + else + gather [ + instr (IMisc (BareThis NoNotice)); + Emit_pos.emit_pos outer_pos; + instr_not + ] | A.Dollar e -> gather [ emit_expr ~need_ref:false env e; -- 2.11.4.GIT