diff --git a/jerry-core/parser/js/parser.cpp b/jerry-core/parser/js/parser.cpp index e721453f3..f4e60ba9b 100644 --- a/jerry-core/parser/js/parser.cpp +++ b/jerry-core/parser/js/parser.cpp @@ -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; } diff --git a/tests/jerry/func-decl.js b/tests/jerry/func-decl.js index 97d0ace93..163842e26 100644 --- a/tests/jerry/func-decl.js +++ b/tests/jerry/func-decl.js @@ -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'; }");