Category
language / compiler
Problem
For backed enums (enum E: string / enum E: int), every case must declare an explicit backing value. Zend fatals at compile time:
Case A of backed enum E must have a value
This compiler accepts case A; without a value and emits an empty unit-style enum (no fatal).
php-src reference
Repro
test/fixtures/parity/backed_enum_missing_value.php:
<?php
enum E: string {
case A;
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/fixtures/parity/backed_enum_missing_value.php; echo zend:$?
php bin/vm.php test/fixtures/parity/backed_enum_missing_value.php; echo vm:$?
'
| Engine |
Result |
| Zend PHP 8.2 |
Fatal: Case A of backed enum E must have a value |
| VM |
Compiles silently (exit 0) |
Scope
| Area |
Files |
| Compiler |
enum declaration lowering / lib/Compiler/ enum validation |
| Tests |
compliance phpt |
Done when
Links
Category
language/compilerProblem
For backed enums (
enum E: string/enum E: int), every case must declare an explicit backing value. Zend fatals at compile time:Case A of backed enum E must have a valueThis compiler accepts
case A;without a value and emits an empty unit-style enum (no fatal).php-src reference
Zend/zend_compile.c— backed enum case validation during compileZend/zend_enum.c— enum case materializationRepro
test/fixtures/parity/backed_enum_missing_value.php:Case A of backed enum E must have a valueScope
lib/Compiler/enum validationDone when
Links