Skip to content

Language: clone() on enum unit cases — Error exception (Zend zend_clones.c parity) #3554

Description

@PurHur

Category

language

Problem

Cloning an enum case must throw Error in Zend; this compiler throws LogicException: clone requires an object.

<?php
enum E { case A; }
try {
    clone E::A;
} catch (Throwable $e) {
    echo get_class($e), "\n";
}
Engine Exception
Zend PHP Error
VM LogicException

Backed enum cases share the same restriction.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
# LogicException

php repro.php
# Error

Expected behavior

Implementation hints

  • VM clone opcode / builtin: detect enum case objects before generic object clone
  • Use Error (not LogicException) via VM exception class table

Acceptance

  • test/compliance/cases/language/clone_enum_case_error.phpt

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on May 30, 2026
  2. PurHur commented on May 30, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-c — starting this run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions