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:
committed by
Evgeny Gavrin
parent
444bd32d50
commit
ec02ace0e9
@@ -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_DECL:
|
||||||
case VARG_FUNC_EXPR:
|
case VARG_FUNC_EXPR:
|
||||||
{
|
|
||||||
syntax_start_checking_of_vargs ();
|
|
||||||
/* FALLTHRU */
|
|
||||||
}
|
|
||||||
case VARG_CONSTRUCT_EXPR:
|
case VARG_CONSTRUCT_EXPR:
|
||||||
{
|
{
|
||||||
current_token_must_be (TOK_OPEN_PAREN);
|
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_DECL:
|
||||||
case VARG_FUNC_EXPR:
|
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);
|
res = rewrite_varg_header_set_args_count (args_num);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -638,6 +633,8 @@ parse_function_declaration (void)
|
|||||||
serializer_set_scope (STACK_TOP (scopes));
|
serializer_set_scope (STACK_TOP (scopes));
|
||||||
scopes_tree_set_strict_mode (STACK_TOP (scopes), scopes_tree_strict_mode (STACK_HEAD (scopes, 2)));
|
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)));
|
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);
|
parse_argument_list (VARG_FUNC_DECL, name, NULL, NULL);
|
||||||
|
|
||||||
dump_function_end_for_rewrite ();
|
dump_function_end_for_rewrite ();
|
||||||
@@ -657,6 +654,8 @@ parse_function_declaration (void)
|
|||||||
|
|
||||||
inside_function = was_in_function;
|
inside_function = was_in_function;
|
||||||
|
|
||||||
|
syntax_check_for_syntax_errors_in_formal_param_list (is_strict_mode (), tok.loc);
|
||||||
|
|
||||||
STACK_DROP (scopes, 1);
|
STACK_DROP (scopes, 1);
|
||||||
serializer_set_scope (STACK_TOP (scopes));
|
serializer_set_scope (STACK_TOP (scopes));
|
||||||
lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes)));
|
lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes)));
|
||||||
@@ -676,6 +675,8 @@ parse_function_expression (void)
|
|||||||
|
|
||||||
operand res;
|
operand res;
|
||||||
|
|
||||||
|
syntax_start_checking_of_vargs ();
|
||||||
|
|
||||||
skip_newlines ();
|
skip_newlines ();
|
||||||
if (token_is (TOK_NAME))
|
if (token_is (TOK_NAME))
|
||||||
{
|
{
|
||||||
@@ -714,6 +715,8 @@ parse_function_expression (void)
|
|||||||
|
|
||||||
inside_function = was_in_function;
|
inside_function = was_in_function;
|
||||||
|
|
||||||
|
syntax_check_for_syntax_errors_in_formal_param_list (is_strict_mode (), tok.loc);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with 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'; function arguments () {}");
|
||||||
check_syntax_error ("'use strict'; var l = function arguments () {}");
|
check_syntax_error ("'use strict'; var l = function arguments () {}");
|
||||||
|
|
||||||
|
check_syntax_error ("function f__strict_mode_duplicate_parameters (p, p) { 'use strict'; }");
|
||||||
|
|||||||
Reference in New Issue
Block a user