Skip to content

PHP 8.6: Assignment-result writes compile but fail with invalid opcode #24792

Open

Description

@alwyn1024

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

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

  1. added a commit that references this issue on Nov 3, 2026
    5089bcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions