Fix syntax check of literal duplication in FormalParameterList (strict mode).

Related issue: #381

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan
2015-07-15 22:49:08 +03:00
committed by Evgeny Gavrin
parent 352e8f5c04
commit d11dfc5703
3 changed files with 47 additions and 21 deletions
+3 -4
View File
@@ -235,11 +235,9 @@ jsp_early_error_check_for_eval_and_arguments_in_strict_mode (operand op, bool is
void void
jsp_early_error_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc __attr_unused___) jsp_early_error_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc __attr_unused___)
{ {
if (STACK_SIZE (props) - STACK_TOP (size_t_stack) < 2 || !is_strict) if (is_strict
&& STACK_SIZE (props) - STACK_TOP (size_t_stack) >= 2)
{ {
STACK_DROP (size_t_stack, 1);
return;
}
for (size_t i = (STACK_TOP (size_t_stack) + 1u); i < STACK_SIZE (props); i++) for (size_t i = (STACK_TOP (size_t_stack) + 1u); i < STACK_SIZE (props); i++)
{ {
JERRY_ASSERT (STACK_ELEMENT (props, i).type == VARG); JERRY_ASSERT (STACK_ELEMENT (props, i).type == VARG);
@@ -262,6 +260,7 @@ jsp_early_error_check_for_syntax_errors_in_formal_param_list (bool is_strict, lo
} }
} }
} }
}
STACK_DROP (props, (size_t) (STACK_SIZE (props) - STACK_TOP (size_t_stack))); STACK_DROP (props, (size_t) (STACK_SIZE (props) - STACK_TOP (size_t_stack)));
STACK_DROP (size_t_stack, 1); STACK_DROP (size_t_stack, 1);
+22
View File
@@ -0,0 +1,22 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
function f_0(){
'use strict';
var v_0 = {
p_0: function(a_0, a_1) {}
};
f_1(function(a_2) {});
}
+5
View File
@@ -69,3 +69,8 @@ try
{ {
assert (e instanceof TypeError); assert (e instanceof TypeError);
} }
(function (a) {
(function (a) {
});
});