Fix propagation of strict mode.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan
2015-06-29 23:59:13 +03:00
committed by Evgeny Gavrin
parent 438d2c2930
commit b45302ee07
2 changed files with 26 additions and 1 deletions
+11 -1
View File
@@ -373,6 +373,8 @@ parse_property_assignment (void)
return;
}
bool is_outer_scope_strict = is_strict_mode ();
const operand name = parse_property_name ();
syntax_add_prop_name (name, is_setter ? PROP_SET : PROP_GET);
@@ -405,6 +407,9 @@ parse_property_assignment (void)
inside_function = was_in_function;
scopes_tree_set_strict_mode (STACK_TOP (scopes), is_outer_scope_strict);
lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes)));
if (is_setter)
{
dump_prop_setter_decl (name, func);
@@ -675,13 +680,15 @@ parse_function_expression (void)
operand res;
bool is_outer_scope_strict = is_strict_mode ();
syntax_start_checking_of_vargs ();
skip_newlines ();
if (token_is (TOK_NAME))
{
const operand name = literal_operand (token_data_as_lit_cp ());
syntax_check_for_eval_and_arguments_in_strict_mode (name, is_strict_mode (), tok.loc);
syntax_check_for_eval_and_arguments_in_strict_mode (name, is_outer_scope_strict, tok.loc);
skip_newlines ();
res = parse_argument_list (VARG_FUNC_EXPR, name, NULL, NULL);
@@ -717,6 +724,9 @@ parse_function_expression (void)
syntax_check_for_syntax_errors_in_formal_param_list (is_strict_mode (), tok.loc);
scopes_tree_set_strict_mode (STACK_TOP (scopes), is_outer_scope_strict);
lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes)));
return res;
}
+15
View File
@@ -38,3 +38,18 @@ 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'; }");
function test_strict_mode_propagation_in_func_expr_and_getters_setters () {
var p = function () {
'use strict';
return true;
}
var o = { get prop () { 'use strict'; return true; }, set prop (v) { 'use strict'; } };
function test () {
tmp_eval = eval;
eval = tmp_eval;
}
}