Skip to content

Regression: static typed enum property default compile-rejected — re-#9975 (Zend/zend_compile.c) #10029

Description

@PurHur

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

  • static_enum_property_default.phpt green on VM
  • JIT/AOT compile the fixture when in scope for enum static defaults
  • ./script/ci-fast.sh --filter static_enum_property_default green

Related

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

    IMPORTANTCritical patharea:compilerCompiler / CFG / JITarea:vmVirtual machineimplementation-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