Fix syntax check for duplicate parameter names in a strict mode function.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan 2015-06-30 00:11:04 +03:00 committed by Evgeny Gavrin
parent 444bd32d50
commit ec02ace0e9
2 changed files with 11 additions and 6 deletions

View File

@ -435,10 +435,6 @@ parse_argument_list (varg_list_type vlt, operand obj, uint8_t *args_count, opera
{
case VARG_FUNC_DECL:
case VARG_FUNC_EXPR:
{
syntax_start_checking_of_vargs ();
/* FALLTHRU */
}
case VARG_CONSTRUCT_EXPR:
{
current_token_must_be (TOK_OPEN_PAREN);
@ -590,7 +586,6 @@ parse_argument_list (varg_list_type vlt, operand obj, uint8_t *args_count, opera
case VARG_FUNC_DECL:
case VARG_FUNC_EXPR:
{
syntax_check_for_syntax_errors_in_formal_param_list (is_strict_mode (), tok.loc);
res = rewrite_varg_header_set_args_count (args_num);
break;
}
@ -638,6 +633,8 @@ parse_function_declaration (void)
serializer_set_scope (STACK_TOP (scopes));
scopes_tree_set_strict_mode (STACK_TOP (scopes), scopes_tree_strict_mode (STACK_HEAD (scopes, 2)));
lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes)));
syntax_start_checking_of_vargs ();
parse_argument_list (VARG_FUNC_DECL, name, NULL, NULL);
dump_function_end_for_rewrite ();
@ -657,6 +654,8 @@ parse_function_declaration (void)
inside_function = was_in_function;
syntax_check_for_syntax_errors_in_formal_param_list (is_strict_mode (), tok.loc);
STACK_DROP (scopes, 1);
serializer_set_scope (STACK_TOP (scopes));
lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes)));
@ -676,6 +675,8 @@ parse_function_expression (void)
operand res;
syntax_start_checking_of_vargs ();
skip_newlines ();
if (token_is (TOK_NAME))
{
@ -714,6 +715,8 @@ parse_function_expression (void)
inside_function = was_in_function;
syntax_check_for_syntax_errors_in_formal_param_list (is_strict_mode (), tok.loc);
return res;
}

View File

@ -1,4 +1,4 @@
// Copyright 2014 Samsung Electronics Co., Ltd.
// Copyright 2015 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -36,3 +36,5 @@ function check_syntax_error (s) {
check_syntax_error ("'use strict'; function arguments () {}");
check_syntax_error ("'use strict'; var l = function arguments () {}");
check_syntax_error ("function f__strict_mode_duplicate_parameters (p, p) { 'use strict'; }");