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

From: Date: Sat, 04 Dec 2021 22:25:26 +0000
Subject: Bug #81684 [Com]: Using null coalesce assignment with $GLOBALS["x"] produces opcode error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238184@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
 Comment 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
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Windows 10 (64Bit)
 PHP Version:        8.1.0
 Block user comment: N
 Private report:     N

 New Comment:

Proposed patch here:
https://github.com/php/php-src/pull/7717


Previous Comments:
------------------------------------------------------------------------
[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


Thread (4 messages)

« previous php.bugs (#238184) next »