diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-08 17:29:41 +0200 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-10-08 17:29:41 +0200 |
| commit | bea832cbf6b7a06ee65b93902233864c1ac9ec98 (patch) | |
| tree | 2fbdca7945a152c7f1476c5e2a14e9b006e2cb1a /Zend/zend_compile.c | |
| parent | 21148679d1dfb614404c09a918d9d2b74f120640 (diff) | |
| download | php-git-bea832cbf6b7a06ee65b93902233864c1ac9ec98.tar.gz | |
Don't check type of simple parameter default values
After fixing the int->double coercion case, this is already verified
at compile-time, so there is no need to redo this type check on
every call.
Only perform the type check every time for the case of AST default
values.
Diffstat (limited to 'Zend/zend_compile.c')
| -rw-r--r-- | Zend/zend_compile.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 255b89d95f..ce37710dd0 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5392,10 +5392,6 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ op_array->required_num_args = i + 1; } - opline = zend_emit_op(NULL, opcode, NULL, &default_node); - SET_NODE(opline->result, &var_node); - opline->op1.num = i + 1; - arg_info = &arg_infos[i]; arg_info->name = zend_string_copy(name); arg_info->pass_by_reference = is_ref; @@ -5443,6 +5439,7 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters " "with a float type can only be float, integer, or NULL"); } + convert_to_double(&default_node.u.constant); break; case IS_ITERABLE: @@ -5467,7 +5464,13 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ } } } + } + opline = zend_emit_op(NULL, opcode, NULL, &default_node); + SET_NODE(opline->result, &var_node); + opline->op1.num = i + 1; + + if (type_ast) { /* Allocate cache slot to speed-up run-time class resolution */ if (opline->opcode == ZEND_RECV_INIT) { if (ZEND_TYPE_IS_CLASS(arg_info->type)) { |
