Skip to content

Commit ec02ace

Browse files
ruben-ayrapetyanegavrin
authored andcommitted
Fix syntax check for duplicate parameter names in a strict mode function.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected]
1 parent 444bd32 commit ec02ace

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

jerry-core/parser/js/parser.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,6 @@ parse_argument_list (varg_list_type vlt, operand obj, uint8_t *args_count, opera
435435
{
436436
case VARG_FUNC_DECL:
437437
case VARG_FUNC_EXPR:
438-
{
439-
syntax_start_checking_of_vargs ();
440-
/* FALLTHRU */
441-
}
442438
case VARG_CONSTRUCT_EXPR:
443439
{
444440
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
590586
case VARG_FUNC_DECL:
591587
case VARG_FUNC_EXPR:
592588
{
593-
syntax_check_for_syntax_errors_in_formal_param_list (is_strict_mode (), tok.loc);
594589
res = rewrite_varg_header_set_args_count (args_num);
595590
break;
596591
}
@@ -638,6 +633,8 @@ parse_function_declaration (void)
638633
serializer_set_scope (STACK_TOP (scopes));
639634
scopes_tree_set_strict_mode (STACK_TOP (scopes), scopes_tree_strict_mode (STACK_HEAD (scopes, 2)));
640635
lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes)));
636+
637+
syntax_start_checking_of_vargs ();
641638
parse_argument_list (VARG_FUNC_DECL, name, NULL, NULL);
642639

643640
dump_function_end_for_rewrite ();
@@ -657,6 +654,8 @@ parse_function_declaration (void)
657654

658655
inside_function = was_in_function;
659656

657+
syntax_check_for_syntax_errors_in_formal_param_list (is_strict_mode (), tok.loc);
658+
660659
STACK_DROP (scopes, 1);
661660
serializer_set_scope (STACK_TOP (scopes));
662661
lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes)));
@@ -676,6 +675,8 @@ parse_function_expression (void)
676675

677676
operand res;
678677

678+
syntax_start_checking_of_vargs ();
679+
679680
skip_newlines ();
680681
if (token_is (TOK_NAME))
681682
{
@@ -714,6 +715,8 @@ parse_function_expression (void)
714715

715716
inside_function = was_in_function;
716717

718+
syntax_check_for_syntax_errors_in_formal_param_list (is_strict_mode (), tok.loc);
719+
717720
return res;
718721
}
719722

tests/jerry/func-decl.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 Samsung Electronics Co., Ltd.
1+
// Copyright 2015 Samsung Electronics Co., Ltd.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -36,3 +36,5 @@ function check_syntax_error (s) {
3636

3737
check_syntax_error ("'use strict'; function arguments () {}");
3838
check_syntax_error ("'use strict'; var l = function arguments () {}");
39+
40+
check_syntax_error ("function f__strict_mode_duplicate_parameters (p, p) { 'use strict'; }");

0 commit comments

Comments
 (0)