Function declaration outside of blocks in direct eval must be ES5.1 compatible. (#3690)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2020-04-24 10:45:14 +02:00
committed by GitHub
parent 1b1460e61f
commit dcf8ccfd03
3 changed files with 27 additions and 31 deletions
+4 -1
View File
@@ -2170,10 +2170,13 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
if (func_init_opcode == CBC_INIT_LOCAL && (option_flags & SCANNER_CREATE_VARS_IS_SCRIPT))
{
#if ENABLED (JERRY_ES2015)
if (!(context_p->global_status_flags & ECMA_PARSE_DIRECT_EVAL))
literal.char_p -= data_p[1];
if (!(context_p->global_status_flags & ECMA_PARSE_DIRECT_EVAL)
|| !scanner_scope_find_let_declaration (context_p, &literal))
{
func_init_opcode = CBC_CREATE_VAR_FUNC_EVAL;
}
literal.char_p += data_p[1];
#else /* !ENABLED (JERRY_ES2015) */
func_init_opcode = CBC_CREATE_VAR_FUNC_EVAL;
#endif /* ENABLED (JERRY_ES2015) */