Category
language — regression · php-src-strict
Problem
Two backed enum cases with the same backing value must compile in Zend; the duplicate is detected at first use (Error: Duplicate value in enum E for cases A and B). VM compiles but materializes cases as backing scalars — no duplicate error and property access on int fails silently.
Closed #5773 / #8687 tracked this; behavior regressed or was never wired on VM enum case fetch.
php-src reference
Repro
test/repro/parity_enum_duplicate_backing.php:
<?php
declare(strict_types=1);
enum E: int { case A = 1; case B = 1; }
echo E::A->name, "\n";
php test/repro/parity_enum_duplicate_backing.php
# Zend: Fatal Error: Duplicate value in enum E for cases A and B
php bin/vm.php test/repro/parity_enum_duplicate_backing.php
# VM today: Warning Attempt to read property "name" on int (E::A materialized as int)
|
Zend |
VM today |
E::A->name after duplicate backing |
Error: Duplicate value... |
warning on int, no Error |
Scope
- VM enum case resolution in
lib/VM/EnumCaseSupport.php (or equivalent)
- Compiler may keep allowing duplicate declarations (Zend compiles)
- PHP-in-PHP — no new C runtime
Done when
Links
#5773 · #8687 · #8746 · #1492
Category
language— regression · php-src-strictProblem
Two backed enum cases with the same backing value must compile in Zend; the duplicate is detected at first use (
Error: Duplicate value in enum E for cases A and B). VM compiles but materializes cases as backing scalars — no duplicate error and property access onintfails silently.Closed #5773 / #8687 tracked this; behavior regressed or was never wired on VM enum case fetch.
php-src reference
Zend/zend_enum.c—zend_enum_get_case_objectduplicate detectionRepro
test/repro/parity_enum_duplicate_backing.php:E::A->nameafter duplicate backingError: Duplicate value...Scope
lib/VM/EnumCaseSupport.php(or equivalent)Done when
Errorwith duplicate message on VMtest/compliance/cases/language/enum_duplicate_backing.phptgreenLinks
#5773 · #8687 · #8746 · #1492