mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix syntax check for case 'eval' or 'arguments' identifiers are used for name of function in strict mode.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
parent
7b90d54490
commit
0422e2230d
@ -631,6 +631,8 @@ parse_function_declaration (void)
|
||||
token_after_newlines_must_be (TOK_NAME);
|
||||
const operand name = literal_operand (token_data_as_lit_cp ());
|
||||
|
||||
syntax_check_for_eval_and_arguments_in_strict_mode (name, is_strict_mode (), tok.loc);
|
||||
|
||||
skip_newlines ();
|
||||
STACK_PUSH (scopes, scopes_tree_init (STACK_TOP (scopes)));
|
||||
serializer_set_scope (STACK_TOP (scopes));
|
||||
@ -678,6 +680,8 @@ parse_function_expression (void)
|
||||
if (token_is (TOK_NAME))
|
||||
{
|
||||
const operand name = literal_operand (token_data_as_lit_cp ());
|
||||
syntax_check_for_eval_and_arguments_in_strict_mode (name, is_strict_mode (), tok.loc);
|
||||
|
||||
skip_newlines ();
|
||||
res = parse_argument_list (VARG_FUNC_EXPR, name, NULL, NULL);
|
||||
}
|
||||
|
||||
@ -23,3 +23,16 @@ assert ((function() {
|
||||
}
|
||||
return f();
|
||||
})() === 'bar');
|
||||
|
||||
function check_syntax_error (s) {
|
||||
try {
|
||||
eval (s);
|
||||
assert (false);
|
||||
}
|
||||
catch (e) {
|
||||
assert (e instanceof SyntaxError);
|
||||
}
|
||||
}
|
||||
|
||||
check_syntax_error ("'use strict'; function arguments () {}");
|
||||
check_syntax_error ("'use strict'; var l = function arguments () {}");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user