Propagate strict mode flag from scanner when parsing functions (#4262)

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
This commit is contained in:
Dániel Bátyai
2020-10-06 10:25:13 +02:00
committed by GitHub
parent fb1c21beb7
commit 17c8ec57bb
4 changed files with 20 additions and 1 deletions
+14
View File
@@ -1822,6 +1822,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
#if ENABLED (JERRY_ESNEXT)
bool has_complex_argument = (context_p->next_scanner_info_p->u8_arg & SCANNER_FUNCTION_HAS_COMPLEX_ARGUMENT) != 0;
#endif /* ENABLED (JERRY_ESNEXT) */
bool is_strict = (context_p->next_scanner_info_p->u8_arg & SCANNER_FUNCTION_IS_STRICT) != 0;
scanner_create_variables (context_p, SCANNER_CREATE_VARS_IS_FUNCTION_ARGS);
scanner_set_active (context_p);
@@ -2099,6 +2100,11 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
#endif /* ENABLED (JERRY_ESNEXT) */
scanner_create_variables (context_p, SCANNER_CREATE_VARS_IS_FUNCTION_BODY);
if (is_strict)
{
context_p->status_flags |= PARSER_IS_STRICT;
}
} /* parser_parse_function_arguments */
#ifndef JERRY_NDEBUG
@@ -2264,6 +2270,14 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
context.module_current_node_p = NULL;
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
JERRY_ASSERT (context.next_scanner_info_p->source_p == context.source_p);
JERRY_ASSERT (context.next_scanner_info_p->type == SCANNER_TYPE_FUNCTION);
if (context.next_scanner_info_p->u8_arg & SCANNER_FUNCTION_IS_STRICT)
{
context.status_flags |= PARSER_IS_STRICT;
}
PARSER_TRY (context.try_buffer)
{
/* Pushing a dummy value ensures the stack is never empty.
+5
View File
@@ -775,6 +775,11 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
{
u8_arg |= SCANNER_FUNCTION_LEXICAL_ENV_NEEDED;
}
if (status_flags & SCANNER_LITERAL_POOL_IS_STRICT)
{
u8_arg |= SCANNER_FUNCTION_IS_STRICT;
}
#endif /* ENABLED (JERRY_ESNEXT) */
info_p->u8_arg = u8_arg;
+1
View File
@@ -236,6 +236,7 @@ typedef enum
* this flag must be combined with the type of function (e.g. async) */
SCANNER_FUNCTION_ASYNC = (1 << 4), /**< function is async function */
#endif /* ENABLED (JERRY_ESNEXT) */
SCANNER_FUNCTION_IS_STRICT = (1 << 5), /**< function is strict */
} scanner_function_flags_t;
/**
-1
View File
@@ -302,7 +302,6 @@
<test id="language/expressions/tagged-template/cache-identical-source-new-function.js"><reason></reason></test>
<test id="language/line-terminators/S7.3_A2.3.js"><reason>No longer a SyntaxError in ES11</reason></test>
<test id="language/line-terminators/S7.3_A2.4.js"><reason>No longer a SyntaxError in ES11</reason></test>
<test id="language/literals/string/7.8.4-1-s.js"><reason></reason></test>
<test id="language/module-code/export-unresolvable.js"><reason></reason></test>
<test id="language/statements/class/definition/this-check-ordering.js"><reason></reason></test>
<test id="language/statements/class/syntax/early-errors/class-body-static-method-get-propname-prototype.js"><reason></reason></test>