Skip to content

Regression: clone($obj, [...]) / clone-with desugars to undefined phpc_clone_with_begin() (re-#9803, Zend/zend_clones.c) #22856

Description

@PurHur

Category

Language · php-src-strict · clone-with / readonly reinit (re-#9803, #16676, #7250, #10108)

Problem

Under PHP_COMPILER_PROFILE=8.4 (and 8.5/8.6), CloneWithDesugar rewrites clone($obj, ['prop' => $v]) / clone $obj with { … } into calls to phpc_clone_with_begin / phpc_clone_with_end / phpc_clone_with_reinit. Those helpers are listed in ext/standard/Module.php but are not callable on the VM/JIT path — execution dies with Error: Call to undefined function phpc_clone_with_begin().

function_exists('phpc_clone_with_begin') is also false. Host unit suite CloneWithTest reports 10 errors + 1 failure on the same undefined-helper symptom (2026-07-24).

Repro Zend 8.4+ (php-src) VM PROFILE=8.4 (2026-07-24)
clone($a, ['x' => 2]) then echo $b->x,$b->y 2,9 Error: Call to undefined function phpc_clone_with_begin()
clone $c with { x: 2 } (readonly reinit) 2 same undefined helper
function_exists('phpc_clone_with_begin') n/a (user API) false

Host Zend 8.2 correctly parse-fatals the syntax; the gap is forward-profile clone-with acceptance without a working runtime helper.

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/repro/clone_with_phpc_begin_undefined.php'
# also: PHP_COMPILER_PROFILE=8.4 ./script/phpunit.sh --filter CloneWithTest

Minimal inline:

./script/docker-exec.sh -- bash -lc "PHP_COMPILER_PROFILE=8.4 php bin/vm.php -r 'class C{public function __construct(public int \$x=1,public int \$y=0){}} \$a=new C(1,9); \$b=clone(\$a,[\"x\"=>2]); echo \$b->x,\",\",\$b->y,\"\\n\";'"

Done when

  • clone($obj, ['x' => 2]) and clone $obj with { x: 2 } succeed on VM under PROFILE=8.4 with Zend-matching property overrides / readonly reinit
  • CloneWithTest green (VM + JIT when LLVM present)
  • Compliance .phpt under test/compliance/cases/ for clone-with
  • php-src-strict; no php-compiler-strict shortcut

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITbugSomething isn't workingimplementation-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