Category
bug · AOT compile-fail · file-scope const holding enum case
Problem
Thin-AOT const X = E::A (file-scope) registers the enum case on the VM as TYPE_OBJECT / enum singleton, then Context::constantFetch('X') hits Non-implemented constant fetch type: 5. Class-const class C { const K = E::A; } already works after #31967 / #32011 via VmConstantJit + TYPE_ENUM_CASE rematerialization — file-scope CONST_FETCH was not wired.
./script/aot-smoke.sh is 8/8.
| Repro |
Zend 8.2 / VM |
AOT (master) |
enum E: int { case A = 1; } const X = E::A; echo X->value; |
1 |
compile LogicException type 5 |
enum E: string { case A = 'hi'; } const X = E::A; echo X->value; |
hi |
same |
enum E { case A; } const X = E::A; echo X->name; |
A |
same |
class-const control class C { const K = E::A; } |
matches |
matches (already green) |
php-src reference
PHP implementation target
Repro
./script/aot-smoke.sh
./script/docker-exec.sh -- bash -lc 'printf "%s\n" "<?php" "enum E: int { case A = 1; }" "const X = E::A;" "echo X->value, PHP_EOL;" > /tmp/fec.php; php /tmp/fec.php; php bin/compile.php -o /tmp/fec.bin /tmp/fec.php && /tmp/fec.bin'
Done when
Category
bug· AOT compile-fail · file-scope const holding enum caseProblem
Thin-AOT
const X = E::A(file-scope) registers the enum case on the VM asTYPE_OBJECT/ enum singleton, thenContext::constantFetch('X')hitsNon-implemented constant fetch type: 5. Class-constclass C { const K = E::A; }already works after #31967 / #32011 viaVmConstantJit+TYPE_ENUM_CASErematerialization — file-scopeCONST_FETCHwas not wired../script/aot-smoke.shis 8/8.enum E: int { case A = 1; } const X = E::A; echo X->value;1enum E: string { case A = 'hi'; } const X = E::A; echo X->value;hienum E { case A; } const X = E::A; echo X->name;Aclass C { const K = E::A; }php-src reference
Zend/zend_constants.c—zend_register_constant/ file-scope const valuesZend/zend_enum.c— enum case singletonsPHP implementation target
lib/JIT/Context.phpconstantFetch— handleTYPE_ENUM_CASEandTYPE_OBJECTenum cases via existingVmConstantJit/jitEnumCaseFromBacking(peer AOT: unimplemented lowering — numeric-string arithmetic, NAN spaceship, enum-as-const, variable static call, self:: interface const #31967)runtime/*.cRepro
./script/aot-smoke.sh ./script/docker-exec.sh -- bash -lc 'printf "%s\n" "<?php" "enum E: int { case A = 1; }" "const X = E::A;" "echo X->value, PHP_EOL;" > /tmp/fec.php; php /tmp/fec.php; php bin/compile.php -o /tmp/fec.bin /tmp/fec.php && /tmp/fec.bin'Done when