[php-src] PR #22804: Fix crash when a partial skips a param with a constant default
| From: | iliaal | Date: | Sun, 19 Jul 2026 14:28:44 +0000 |
| Subject: | [php-src] PR #22804: Fix crash when a partial skips a param with a constant default | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-37151@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22804
Author: iliaal
A partial that leaves an optional parameter unbound via a named-argument gap, where that
parameter's default is a constant expression, crashes the compiler.
f(a: 10, c: ?)
for function f($a, $b = SOME_CONST, $c = 0) compiled the callee default into the
generated forwarding call as a ZEND_AST_CONSTANT node, which
zend_compile_expr_inner has no case for: ZEND_ASSERT(0) in debug,
__builtin_unreachable UB in release. A plain literal default ($b = 5) is
unaffected.
For a user function, this skips the unbound parameter in the forwarding call and passes the
following arguments by name, so the target applies its own default at call time. That matches a
normal call exactly (verified for global constants, self:: class constants, and enum
cases) and materializes no value, so it is safe under opcache for defaults that cannot be stored as
a literal, such as enum cases. Internal functions are unchanged: they still pass an explicit default
and error when it is not introspectable.