Fix over-eager named params optimization

We can't relax a named param to a positional param if we encountered
any unknown parameters in the meantime.
This commit is contained in:
Nikita Popov 2020-08-26 11:01:15 +02:00
parent f593019819
commit 1954aed745
2 changed files with 8 additions and 1 deletions

View File

@ -15,6 +15,12 @@ try {
echo $e->getMessage(), "\n";
}
try {
test(b: 2, a: 1);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
test2(a: 42);
} catch (Error $e) {
@ -24,3 +30,4 @@ try {
?>
--EXPECT--
Unknown named parameter $b
Unknown named parameter $b

View File

@ -3369,7 +3369,7 @@ uint32_t zend_compile_args(
if (fbc) {
arg_num = zend_get_arg_num(fbc, arg_name);
if (arg_num == arg_count + 1) {
if (arg_num == arg_count + 1 && !may_have_undef) {
/* Using named arguments, but passing in order. */
arg_name = NULL;
arg_count++;