Delay the variable construction in the function body. (#3289)

Local variables inside the function body should be constructed after the
parameters are initialized. Furthermore arguments should be available
during parameter initialization.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2019-11-08 12:18:23 +01:00
committed by Dániel Bátyai
parent 923fd128b5
commit e1fc90db0e
7 changed files with 223 additions and 92 deletions
+7 -1
View File
@@ -1617,13 +1617,16 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
#endif /* ENABLED (JERRY_ES2015) */
JERRY_ASSERT (context_p->next_scanner_info_p->type == SCANNER_TYPE_FUNCTION);
scanner_create_variables (context_p, SCANNER_CREATE_VARS_NO_OPTS);
if (context_p->token.type == end_type)
{
scanner_create_variables (context_p, SCANNER_CREATE_VARS_NO_OPTS);
return;
}
scanner_create_variables (context_p, SCANNER_CREATE_VARS_IS_FUNCTION_ARGS);
scanner_set_active (context_p);
while (true)
{
#if ENABLED (JERRY_ES2015)
@@ -1730,6 +1733,9 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
parser_raise_error (context_p, error);
}
scanner_revert_active (context_p);
scanner_create_variables (context_p, SCANNER_CREATE_VARS_IS_FUNCTION_BODY);
} /* parser_parse_function_arguments */
/**