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:
Ruben Ayrapetyan 2015-06-29 23:42:49 +03:00 committed by Evgeny Gavrin
parent 7b90d54490
commit 0422e2230d
2 changed files with 17 additions and 0 deletions

View File

@ -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);
}

View File

@ -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 () {}");