Skip to content

Fix enum case method first-class callable E::A->f(...) (#6845) - #6860

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-6845-enum-case-fcc-method
Jun 6, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-6845-enum-case-fcc-method

Conversation

@PurHur

@PurHur PurHur commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • ClosureSupport::fromArrayCallable() materializes TYPE_ENUM_CASE receivers via EnumCaseSupport::receiverForInstanceMethod() so E::A->f(...) produces a working Closure (php-src zend_closures.c).
  • JIT FromCallableHelper / BoundMethodCallableHelper infer enum FQCN from TYPE_CLASS_CONST_FETCH when lowering bound-method FCC arrays.

Closes #6845

php-src reference

  • Zend/zend_compile.c — first-class callable lowering
  • Zend/zend_closures.c — enum case method binding

Verification

Issue repro:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_enum_case_first_class_callable.php
php test/repro/maintainer_enum_case_first_class_callable.php
'

Output:

a
a

Targeted tests:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
./vendor/bin/phpunit --filter FirstClassCallableTest
./vendor/bin/phpunit --filter enum_case_method_first_class_callable
'

Output: OK (12 tests including compliance .phpt).

Made with Cursor

Closure::fromCallable rejected TYPE_ENUM_CASE array receivers; materialize
the enum case object and infer enum class names for JIT FCC lowering.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant