Skip to content

Language: enum case instance method first-class callable (... ) — compile fails PHPTypes (Zend/zend_compile.c) #9398

Description

@PurHur

Category

language · php-src-strict

Problem

First-class callable syntax on enum case instance methods (E::A->m(...)) is valid in Zend/php-src (PHP 8.1+). This compiler fails during compile/type reconstruction with Call to undefined method PHPTypes\Type::array() (vendor PHPTypes\TypeReconstructor) instead of lowering the callable.

Blocks enum APIs using ... for case methods and self-host when vendor/spine code uses the pattern.

php-src reference

Repro

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

Control (plain call — must work before/after):

<?php
enum E: string { case A = 'a'; public function m(): string { return 'm'; } }
echo E::A->m(), "\n";

Scope (this repo)

Path Work
lib/Compiler.php / AST lowering First-class callable on enum case receivers
lib/Runtime.php / PHPTypes integration Fix type reconstructor for enum-case ...
lib/VM.php Runtime callable binding for enum case methods
Tests test/compliance/cases/language/enum_case_first_class_callable.phpt

Done when

  • Repro compiles and prints m on VM
  • Plain E::A->m() control unchanged
  • JIT/AOT agree if first-class callable is in scope for the issue PR

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