Permalink
Browse files

Fix isset on pseudoglobals

Summary: Fixes #8187

Reviewed By: fredemmott

Differential Revision: D7953851
  • Loading branch information...
oulgen authored and fredemmott committed May 11, 2018
1 parent 3336daa commit 950b326f6dbe036a89ab7c227c3f2ecc2689af81
@@ -1169,14 +1169,21 @@ and emit_call_isset_expr env outer_pos (pos, expr_ as expr) =
gather [
emit_expr ~need_ref:false env e;
emit_pos outer_pos;
instr (IIsset IssetG)
instr_issetg
]
| A.Array_get (base_expr, opt_elem_expr) ->
emit_array_get ~need_ref:false env pos None QueryOp.Isset base_expr opt_elem_expr
| A.Class_get (cid, id) ->
emit_class_get env None QueryOp.Isset false cid id
| A.Obj_get (expr, prop, nullflavor) ->
emit_obj_get ~need_ref:false env pos None QueryOp.Isset expr prop nullflavor
| A.Lvar (_, n) when SN.Superglobals.is_superglobal n ->
gather [
emit_pos outer_pos;
instr_string @@ SU.Locals.strip_dollar n;
emit_pos outer_pos;
instr_issetg
]
| A.Lvar ((_, name) as id)
when is_local_this env name && not (Emit_env.get_needs_local_this env) ->
gather [
@@ -118,6 +118,7 @@ let instr_setn = instr (IMutator SetN)
let instr_unsetl local = instr (IMutator (UnsetL local))
let instr_issetl local = instr (IIsset (IssetL local))
let instr_issetn = instr (IIsset IssetN)
let instr_issetg = instr (IIsset IssetG)
let instr_issets = instr (IIsset (IssetS class_ref_rewrite_sentinel))
let instr_emptys = instr (IIsset (EmptyS class_ref_rewrite_sentinel))
let instr_emptyn = instr (IIsset EmptyN)
@@ -0,0 +1,10 @@
<?hh
var_dump(isset($_GET));
var_dump(isset($GLOBALS));
$_GET = 1;
$_GET;
unset($_GET);
unset($GLOBALS);
@@ -0,0 +1,2 @@
bool(true)
bool(true)

0 comments on commit 950b326

Please sign in to comment.