|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81684 Using null coalesce assignment with $GLOBALS["x"] produces opcode error
Submitted: 2021-12-01 11:11 UTC Modified: 2021-12-05 17:37 UTC
From: rh at tfli dot co dot uk Assigned: ilutov (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 8.1.0 OS: Windows 10 (64Bit)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: rh at tfli dot co dot uk
New email:
PHP Version: OS:


 [2021-12-01 11:11 UTC] rh at tfli dot co dot uk
On PHP 8.1.0, likely following, then null coalesce assignment no longer works (when used with a key on $GLOBALS).

Test script:

$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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-12-01 12:47 UTC]
-Status: Open +Status: Verified
 [2021-12-01 12:47 UTC]
Right: <>.  Happens also with 8.1.0 (which
is not yet available on
 [2021-12-01 12:47 UTC]
-Package: *General Issues +Package: Scripting Engine problem
 [2021-12-04 22:25 UTC]
Proposed patch here:
 [2021-12-05 00:39 UTC]
-Assigned To: +Assigned To: ilutov
 [2021-12-05 17:37 UTC]
-Status: Verified +Status: Closed
 [2021-12-05 17:37 UTC]
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at

Thanks for the report! Should be fixed in the upcoming PHP 8.1.2 release.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Feb 07 05:03:43 2023 UTC