Skip to content

Regression: enum trait instance methods on cases — Method call on non-object (re-#6623, zend_enum.c) #8808

@PurHur

Description

@PurHur

Category

languageregression

Problem

Enums may use traits with instance methods; calling those methods on enum cases must work like Zend. Closed #5709 / #6623 fixed trait merge on enums, but VM now fails case method dispatch.

php-src reference

Repro

test/repro/maintainer_enum_use_trait.php:

<?php
trait T {
    public function m(): void {
        echo "trait\n";
    }
}
enum E: int {
    use T;
    case A = 1;
}
E::A->m();
php test/repro/maintainer_enum_use_trait.php
# Zend: trait

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_enum_use_trait.php'
# VM today: Method call on non-object
Zend VM today
E::A->m() prints trait Method call on non-object

Scope

  • VM enum case object dispatch — trait-merged methods on backed enum cases
  • JIT/AOT must match when enum method calls are lowered
  • PHP implementation in lib/ / ext/ — no new C runtime branches

Done when

  • Repro prints trait under php bin/vm.php
  • JIT/AOT agree if enum instance calls are in scope
  • Targeted compliance PHPT or repro guard green in ./script/ci-fast.sh
  • php-src-strict

Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-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