Skip to content

Commit 588a482

Browse files
committed
Optimized optimizer.
Added test for default with variadic arguments.
1 parent 082dd45 commit 588a482

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Zend/Optimizer/optimize_func_calls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ static void zend_try_inline_call(zend_op_array *op_array, zend_op *fcall, zend_o
117117
} while (i < func->op_array.num_args);
118118
}
119119

120-
for (i = 0; i < op_array->last; i++) {
120+
for (zend_op *op = fcall + 1; op != opline; ++op) {
121121
// Don't inline calls with explicit default arguments.
122-
if (op_array->opcodes[i].opcode == ZEND_FETCH_DEFAULT_ARG) {
122+
if (op->opcode == ZEND_FETCH_DEFAULT_ARG) {
123123
return;
124124
}
125125
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Tests passing default to a variadic parameter
3+
--FILE--
4+
<?php
5+
6+
(fn (...$V) => $V)(default);
7+
?>
8+
--EXPECTF--
9+
Fatal error: Uncaught ValueError: Cannot pass default to undeclared parameter 1 of {closure:%s:%d}() in %s:%d
10+
Stack trace:
11+
%a

0 commit comments

Comments
 (0)