Skip to content

Stdlib: is_callable() on enum case first-class callable returns false — invoke succeeds (Zend/zend_callable.c) #9758

Description

@PurHur

Category

language · stdlib · php-src-strict

Problem

Enum case instance method first-class callables (E::Case->method(...)) compile and invoke correctly, but is_callable() returns false while Zend returns true. This breaks guards that gate invocation on is_callable() before calling.

Related compile work: #9398 (FCC parse). This issue is the runtime is_callable() probe once FCC exists.

php-src reference

Repro

<?php
enum E: int {
    case A = 1;
    public function m(): string { return 'ok'; }
}

var_export(is_callable([E::A, 'm']));
echo "\n";
var_export(is_callable(E::A->m(...)));
echo "\n";
$c = E::A->m(...);
var_export($c());
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php test/repro/enum_case_fcc_is_callable.php; php bin/vm.php test/repro/enum_case_fcc_is_callable.php'
Probe Zend PHP 8.2+ VM today
is_callable([E::A, 'm']) true true
is_callable(E::A->m(...)) true false
(E::A->m(...))() 'ok' 'ok'

Scope (PHP-in-PHP)

Layer Path
VM ext/standard/is_callable.php / callable classification helpers
Shared Treat bound enum-case FCC like other Closure/FirstClassCallable objects
Tests test/compliance/cases/language/enum_case_fcc_is_callable.phpt

Done when (php-src-strict)

  • Repro: is_callable(E::A->m(...)) is true on VM
  • (E::A->m(...))() still returns 'ok'
  • JIT/AOT agree when FCC lowering is in scope

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

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions