Skip to content

AOT: file-scope const X = E::A compile-fails — constantFetch type 5/OBJECT (re-#31967 class-const only, Zend/zend_constants.c) #34783

Description

@PurHur

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

  • AOT matches Zend for int-/string-backed and unit file-scope enum consts
  • class-const control still green
  • targeted phpunit / repro; aot-smoke 8/8

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITbugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions