Implement proper creation of function arguments, let and const declarations. (#3725)

After the rework it is possible to detect use before init errors for function arguments.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2020-05-12 14:38:17 +02:00
committed by GitHub
parent df7e303145
commit 4dc2cb3328
16 changed files with 729 additions and 218 deletions
+19 -5
View File
@@ -176,15 +176,29 @@ scanner_check_arrow_arg (parser_context_t *context_p, /**< context */
}
else
{
scanner_append_argument (context_p, scanner_context_p);
lexer_lit_location_t *argument_literal_p = scanner_append_argument (context_p, scanner_context_p);
scanner_detect_eval_call (context_p, scanner_context_p);
lexer_next_token (context_p);
if (context_p->token.type == LEXER_ASSIGN
|| context_p->token.type == LEXER_COMMA
|| context_p->token.type == LEXER_RIGHT_PAREN)
if (context_p->token.type == LEXER_ASSIGN)
{
if (argument_literal_p->type & SCANNER_LITERAL_IS_USED)
{
JERRY_ASSERT (argument_literal_p->type & SCANNER_LITERAL_EARLY_CREATE);
return;
}
scanner_binding_literal_t binding_literal;
binding_literal.literal_p = argument_literal_p;
parser_stack_push (context_p, &binding_literal, sizeof (scanner_binding_literal_t));
parser_stack_push_uint8 (context_p, SCAN_STACK_BINDING_INIT);
return;
}
if (context_p->token.type == LEXER_COMMA || context_p->token.type == LEXER_RIGHT_PAREN)
{
return;
}
@@ -381,7 +395,7 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
arrow_source_p = NULL;
#endif /* ENABLED (JERRY_ES2015) */
scanner_context_p->active_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_NO_REG;
scanner_context_p->active_literal_pool_p->status_flags |= SCANNER_LITERAL_POOL_CAN_EVAL;
break;
}