Category
language — regression · php-src-strict
Problem
Two backed enum cases with the same backing value must compile in Zend; duplicate detection runs at first use of any case:
enum E: int { case A = 1; case B = 1; }
E::A->name; // Error: Duplicate value in enum E for cases A and B
Issues #8687 / #8876 were closed, but VM still materializes cases as backing scalars — no duplicate Error and property access on int fails with a warning instead.
php-src reference
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_duplicate_enum_backing_value.php
php bin/vm.php test/repro-maintainer/parity_duplicate_enum_backing_value.php
'
| Runtime |
E::A->name |
| Zend |
Error: Duplicate value in enum E for cases A and B |
| VM |
Warning: Attempt to read property "name" on int (no Error) |
Scope
| Layer |
Files |
| VM |
lib/VM/EnumSupport.php — enforce duplicate map on first case materialization |
| Compile |
optional early fatal if both cases are constant-foldable (Zend allows compile) |
| Tests |
test/compliance/cases/language/enum_duplicate_backing_value.phpt |
PHP-in-PHP: duplicate tracking belongs in lib/VM/EnumSupport.php; do not add C runtime branches.
Done when
Related
Category
language— regression · php-src-strictProblem
Two backed enum cases with the same backing value must compile in Zend; duplicate detection runs at first use of any case:
Issues #8687 / #8876 were closed, but VM still materializes cases as backing scalars — no duplicate
Errorand property access onintfails with a warning instead.php-src reference
Zend/zend_enum.c—zend_enum_get_case_object, duplicate backing mapZend/zend_compile.c— enum case table buildRepro
E::A->nameError: Duplicate value in enum E for cases A and BWarning: Attempt to read property "name" on int(no Error)Scope
lib/VM/EnumSupport.php— enforce duplicate map on first case materializationtest/compliance/cases/language/enum_duplicate_backing_value.phptPHP-in-PHP: duplicate tracking belongs in
lib/VM/EnumSupport.php; do not add C runtime branches.Done when
Errorwith Zend message on VM (JIT/AOT same script)./script/ci-fast.sh --filter enum_duplicate_backinggreenRelated