Skip to content

Language: first-class callable syntax — strlen(...) yields NULL not Closure (Zend/zend_compile.c) #9170

Description

@PurHur

Category

language · php-src-strict

Problem (updated Jun 2026 audit)

Mostly fixed on VM for function and static-method FCC:

Form VM Jun 2026 Zend
strlen(...) Closure, invokable yes
C::f(...) static Closure, invokable yes
$obj->m(...) instance compile failure Closure — #9185
Default param strlen(...) compile error (#3803) allowed as constant Closure

This issue tracks remaining FCC gaps after builtin/static fix; instance FCC is split to #9185 for worker claiming.

php-src reference

Repro (still open: default parameter FCC)

<?php
class C {
    public function f(Closure $c = strlen(...)): int {
        return $c('abc');
    }
}
echo (new C)->f(), "\n";
php repro_fcc_default.php          # Zend: 3
php bin/vm.php repro_fcc_default.php 2>&1 | head -3
# parseAndCompile: Parameter default must be a compile-time constant (#3803)
Runtime Result
Zend prints 3
VM compile failure

Instance FCC: see #9185 ($d->m(...)).

Scope (this repo)

Layer Path
Compiler lib/Compiler.php — treat FCC AST as compile-time Closure constant in parameter defaults
VM/JIT Reuse closure materialization from working strlen(...) path
Tests test/compliance/cases/language/fcc_default_parameter.phpt

PHP-in-PHP: lib/ lowering only.

Done when (php-src-strict)

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