Bug #81684 [Ver->Csd]: Using null coalesce assignment with $GLOBALS["x"] produces opcode error

From: Date: Sun, 05 Dec 2021 17:37:26 +0000
Subject: Bug #81684 [Ver->Csd]: Using null coalesce assignment with $GLOBALS["x"] produces opcode error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238198@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81684&edit=1 ID: 81684 Updated by: ilutov@php.net Reported by: rh at tfli dot co dot uk Summary: Using null coalesce assignment with $GLOBALS["x"] produces opcode error -Status: Verified +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Windows 10 (64Bit) PHP Version: 8.1.0 Assigned To: ilutov Block user comment: N Private report: N New Comment: Thank you for your bug report. This issue has already been fixed in the latest released version of PHP, which you can download at http://www.php.net/downloads.php Thanks for the report! Should be fixed in the upcoming PHP 8.1.2 release. Previous Comments: ------------------------------------------------------------------------ [2021-12-04 22:25:26] ilutov@php.net Proposed patch here: https://github.com/php/php-src/pull/7717 ------------------------------------------------------------------------ [2021-12-01 12:47:19] cmb@php.net Right: <https://3v4l.org/Y4146>. Happens also with 8.1.0 (which is not yet available on 3v4l.org). ------------------------------------------------------------------------ [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

« previous php.bugs (#238198) next »