Category
language · php-src-strict · regression
Problem
#9975 was closed, but VM still rejects valid PHP 8.1+ syntax for static typed properties with enum case defaults:
enum G: string { case X = 'x'; }
class C {
public static G $g = G::X;
}
echo C::$g->name; // Zend: X
Compile error today:
Cannot use string as default value for property C::$g of type G
Compliance fixture already exists: test/compliance/cases/language/static_enum_property_default.phpt.
Instance property enum defaults are tracked in #9954; this issue is static only.
php-src reference
Repro (failure today)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/compliance/cases/language/static_enum_property_default.phpt
# parseAndCompile failure: Cannot use string as default value for property C::$g of type G
'
| Step |
Zend |
VM today |
Compile static G $g = G::X |
OK |
compile error ❌ |
C::$g->name |
X |
n/a |
Scope (this repo)
| Path |
Work |
lib/Compiler.php |
Accept enum case expression as default for static typed properties |
lib/VM.php |
Preserve enum singleton at runtime (no backing scalar materialization) |
lib/JIT/ |
Match VM when JIT compiles static property init |
Done when
Related
Category
language· php-src-strict · regressionProblem
#9975 was closed, but VM still rejects valid PHP 8.1+ syntax for static typed properties with enum case defaults:
Compile error today:
Compliance fixture already exists:
test/compliance/cases/language/static_enum_property_default.phpt.Instance property enum defaults are tracked in #9954; this issue is static only.
php-src reference
Zend/zend_compile.c— typed property default validation for enum objectsZend/zend_enum.cZend/tests/enum/backed_enum_properties*.phptRepro (failure today)
static G $g = G::XC::$g->nameXScope (this repo)
lib/Compiler.phplib/VM.phplib/JIT/Done when
static_enum_property_default.phptgreen on VM./script/ci-fast.sh --filter static_enum_property_defaultgreenRelated