Skip to content

Language: first-class callable on enum case methods — parseAndCompile TypeReconstructor crash (zend_compile.c) #6845

Description

@PurHur

Category

language · php-src-strict

Problem

First-class callable syntax on enum case instance methods (E::A->f(...)) must compile and invoke the case method. This compiler crashes during type reconstruction with Call to undefined method PHPTypes\Type::array() when the receiver is an enum case.

Related runtime gap: #5721 (Closure::fromCallable([enumCase, method])).

php-src reference

Repro

test/repro/maintainer_enum_case_first_class_callable.php:

enum E {
    case A;
    public function f(): string { return 'a'; }
}
$c = E::A->f(...);
echo $c(), "\n"; // Zend: a
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_enum_case_first_class_callable.php   # TypeReconstructor crash
php test/repro/maintainer_enum_case_first_class_callable.php              # a
'

Expected

Compile succeeds; runtime prints a.

Actual

parseAndCompile failure: Call to undefined method PHPTypes\Type::array() in TypeReconstructor.php.

Implementation hints (PHP-in-PHP)

Verification

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 / JITarea: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