Repository navigation
Description
Description
Summary
In PHP 8.6.0RC4, writing to an array dimension on an assignment result compiles successfully, but execution fails with an Invalid opcode fatal error.
PHP 8.5.10 rejects the same construct during compilation.
Minimal reproducer
<?php
($a = [1])[0] = 2;
var_dump($a);Actual behavior
PHP 8.5.10: Compilation fails:
Fatal error: Cannot use temporary expression in write context
PHP 8.6.0RC4: php -l succeeds, but executing the code fails:
Fatal error: Invalid opcode 23/2/1.
Reference-assignment control
<?php
$b = [1];
($a =& $b)[0] = 2;
var_dump($a, $b);PHP 8.6.0RC4 accepts and executes this successfully, with both arrays containing [2].
Other assignment-derived property writes, destructuring-result writes, compound assignments, unset, and reference-binding operations exhibit related discrepancies.
Expected behavior / clarification requested
Should assignment-derived dimension and property writes be rejected during compilation, or should PHP generate valid writable operands for these expressions?
In particular, is the ordinary-assignment failure a compiler emission defect, a missing compile-time rejection, or an intentional distinction between ordinary and reference-assignment results?
Affected versions
- PHP 8.5.10 — Windows x64
- PHP 8.6.0RC4 — Windows x64, NTS, VC2022
- PHP 8.6 source commit:
f23b4c222cebe33be93ee8ecaaa14390c5507a08
The PHP 8.6 executable was built from the specified source commit.
Reproduction: php -n -l example.php, followed by php -n example.php.
Relevant implementation
- [zend_compile_var_inner]()
Line 12774 in f23b4c2
switch (ast->kind) { - [ZEND_ASSIGN_DIM handlers]()
Line 2680 in f23b4c2
ZEND_VM_HANDLER(23, ZEND_ASSIGN_DIM, VAR|CV, CONST|TMP|UNUSED|NEXT|CV, SPEC(OP_DATA=CONST|TMP|CV)) - [Related PR #20628](VAR|TMP overhaul #20628)
The compiler appears to allow assignment ASTs in writable contexts while producing operand kinds unsupported by the corresponding VM write handlers.
I would appreciate clarification of the intended behavior before treating these forms as valid or invalid PHP source syntax.
PHP Version
PHP 8.6.0RC4 (cli) (built: Oct 25 2026 12:45:36) (NTS Visual C++ 2022 x64)
Copyright © The PHP Group and Contributors
Zend Engine v4.6.0RC4, Copyright © Zend by Perforce
with Zend OPcache v8.6.0RC4, Copyright ©, by Zend by Perforce
Operating System
Windows x64 (64-bit), PHP 8.6.0RC4 NTS, Visual C++ 2022 (VC17)
Activity
Fix phpGH-24792: Assignment-result writes compile but fail with inval…