Skip to content

Commit c6e68ce

Browse files
committed
Eval called as a bound function should be indirect eval
JerryScript-DCO-1.0-Signed-off-by: Youngil Choi [email protected]
1 parent 98cec9a commit c6e68ce

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

jerry-core/ecma/operations/ecma-function-object.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "ecma-objects-general.h"
2727
#include "ecma-objects-arguments.h"
2828
#include "ecma-try-catch-macro.h"
29+
#include "jcontext.h"
2930

3031
#define JERRY_INTERNAL
3132
#include "jerry-internal.h"
@@ -650,6 +651,7 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
650651
else
651652
{
652653
JERRY_ASSERT (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
654+
JERRY_CONTEXT (is_direct_eval_form_call) = false;
653655

654656
/* 2-3. */
655657
ecma_property_t *bound_this_prop_p;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2016 Samsung Electronics Co., Ltd.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var builtinEval = eval;
16+
var eval = builtinEval.bind(undefined, "context");
17+
18+
var context = "global";
19+
function checkIfDirectEval() {
20+
var context = "function";
21+
return (eval() == "function");
22+
}
23+
24+
assert (!checkIfDirectEval());
25+

0 commit comments

Comments
 (0)