Bug #81684 [NEW]: Using null coalesce assignment with $GLOBALS["x"] produces opcode error

From: Date: Wed, 01 Dec 2021 11:11:16 +0000
Subject: Bug #81684 [NEW]: Using null coalesce assignment with $GLOBALS["x"] produces opcode error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238083@lists.php.net to get a copy of this message
From:             rh at tfli dot co dot uk
Operating system: Windows 10 (64Bit)
PHP version:      8.1.0
Package:          *General Issues
Bug Type:         Bug
Bug description:Using null coalesce assignment with $GLOBALS["x"] produces opcode error

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 bug report at https://bugs.php.net/bug.php?id=81684&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81684&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81684&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81684&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81684&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81684&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81684&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81684&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81684&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81684&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81684&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81684&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81684&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81684&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81684&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81684&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81684&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81684&r=mysqlcfg


Thread (4 messages)

« previous php.bugs (#238083) next »