Category
language · php-src-strict · closures · compile-time fatal
Problem
php-src rejects a closure that lists the same variable twice in use. This compiler accepts use ($a, $a) and runs the body. Distinct from use ($this) (illegal name); this is a duplicate lexical binding.
| Repro |
Zend 8.2+ |
VM/JIT (2026-08-18 @ 8d228396dc) |
$a=1; $f=function() use ($a, $a) { return $a; }; echo "accepted\n"; |
Fatal: Cannot use variable $a twice (rc=255) |
accepted (rc=0) |
php-src reference
PHP implementation target
lib/ closure compile — duplicate use names must compile-fatal with Zend's message including the variable name
- JIT/AOT share the compile path; no C runtime branches
Repro
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_use_dup.php 2>&1 | head -5'
./script/docker-exec.sh -- bash -lc 'php bin/jit.php test/repro/maintainer_gap_use_dup.php 2>&1 | head -5'
Done when
Category
language· php-src-strict · closures · compile-time fatalProblem
php-src rejects a closure that lists the same variable twice in
use. This compiler acceptsuse ($a, $a)and runs the body. Distinct fromuse ($this)(illegal name); this is a duplicate lexical binding.8d228396dc)$a=1; $f=function() use ($a, $a) { return $a; }; echo "accepted\n";accepted(rc=0)php-src reference
Zend/zend_compile.c— closureuselist uniqueness (zend_compile_closure, lexical variable table)PHP implementation target
lib/closure compile — duplicateusenames must compile-fatal with Zend's message including the variable nameRepro
Done when
Cannot use variable $a twice(rc≠0, noacceptedoutput).phptguard undertest/compliance/cases/language/closure_use_duplicate*.phpt