Skip to content

Commit 1954aed

Browse files
committed
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.
1 parent f593019 commit 1954aed

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Zend/tests/named_params/unknown_named_param.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ try {
1515
echo $e->getMessage(), "\n";
1616
}
1717

18+
try {
19+
test(b: 2, a: 1);
20+
} catch (Error $e) {
21+
echo $e->getMessage(), "\n";
22+
}
23+
1824
try {
1925
test2(a: 42);
2026
} catch (Error $e) {
@@ -24,3 +30,4 @@ try {
2430
?>
2531
--EXPECT--
2632
Unknown named parameter $b
33+
Unknown named parameter $b

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3369,7 +3369,7 @@ uint32_t zend_compile_args(
33693369

33703370
if (fbc) {
33713371
arg_num = zend_get_arg_num(fbc, arg_name);
3372-
if (arg_num == arg_count + 1) {
3372+
if (arg_num == arg_count + 1 && !may_have_undef) {
33733373
/* Using named arguments, but passing in order. */
33743374
arg_name = NULL;
33753375
arg_count++;

0 commit comments

Comments
 (0)