Bug #81684 [Opn->Ver]: Using null coalesce assignment with $GLOBALS["x"] produces opcode error
Edit report at https://bugs.php.net/bug.php?id=81684&edit=1
ID: 81684
Updated by: cmb@php.net
Reported by: rh at tfli dot co dot uk
Summary: Using null coalesce assignment with $GLOBALS["x"]
produces opcode error
-Status: Open
+Status: Verified
Type: Bug
Package: *General Issues
Operating System: Windows 10 (64Bit)
PHP Version: 8.1.0
Block user comment: N
Private report: N
New Comment:
Right: <https://3v4l.org/Y4146>. Happens also with 8.1.0
(which
is not yet available on 3v4l.org).
Previous Comments:
------------------------------------------------------------------------
[2021-12-01 11:11:16] rh at tfli dot co dot uk
Description:
------------
On PHP 8.1.0, likely following https://wiki.php.net/rfc/restrict_globals_usage,
then null coalesce assignment no longer works (when used with a key on $GLOBALS).
Test script:
---------------
<?php
$GLOBALS["x"] = $GLOBALS["x"] ?? [];
var_dump($GLOBALS["x"]); // array(0){}
$GLOBALS["y"] ??= []; // Fatal error: Invalid opcode 23/1/0. in /in/Y4146 on line 5
echo "Done."
Expected result:
----------------
The script outputs the first var_dump (as it does presently) and then echoes Done.
Actual result:
--------------
Fatal error: Invalid opcode 23/1/0. in /in/Y4146 on line 5
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81684&edit=1
Thread (4 messages)