Skip to content

Commit 563a5d9

Browse files
authored
Fix 'arguments' and 'caller' properties lazy listing in ES2015 profile (#3539)
This patch fixes #3536. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent 7734f87 commit 563a5d9

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,18 +1814,24 @@ ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, /**< functio
18141814

18151815
/* 'prototype' property is non-enumerable (ECMA-262 v5, 13.2.18) */
18161816
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_PROTOTYPE));
1817+
18171818
#if ENABLED (JERRY_ES2015)
1818-
}
1819+
bool append_caller_and_arguments = !(bytecode_data_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE);
1820+
#else /* !ENABLED (JERRY_ES2015) */
1821+
bool append_caller_and_arguments = (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE);
18191822
#endif /* ENABLED (JERRY_ES2015) */
18201823

1821-
if (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE)
1822-
{
1823-
/* 'caller' property is non-enumerable (ECMA-262 v5, 13.2.5) */
1824-
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER));
1824+
if (append_caller_and_arguments)
1825+
{
1826+
/* 'caller' property is non-enumerable (ECMA-262 v5, 13.2.5) */
1827+
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER));
18251828

1826-
/* 'arguments' property is non-enumerable (ECMA-262 v5, 13.2.5) */
1827-
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_ARGUMENTS));
1829+
/* 'arguments' property is non-enumerable (ECMA-262 v5, 13.2.5) */
1830+
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_ARGUMENTS));
1831+
}
1832+
#if ENABLED (JERRY_ES2015)
18281833
}
1834+
#endif /* ENABLED (JERRY_ES2015) */
18291835
} /* ecma_op_function_list_lazy_property_names */
18301836

18311837
/**

tests/jerry/es2015/function-properties.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var prototype_obj = { dummy:1, length:1, caller:null,
3535
var func = function() {};
3636

3737
Object.setPrototypeOf(func, prototype_obj);
38-
assert(getProperties(func) == "dummy caller arguments");
38+
assert(getProperties(func) == "dummy");
3939

4040
var bound_func = (function() {}).bind(null);
4141
Object.setPrototypeOf(bound_func, prototype_obj);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
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+
class A {
16+
constructor() {
17+
var hasProp = $ => {}
18+
Object.preventExtensions(hasProp);
19+
assert(Object.isSealed(hasProp) === true);
20+
}
21+
super() {
22+
$: $
23+
}
24+
}
25+
class B extends A {
26+
constructor() {
27+
super() (super.super)
28+
}
29+
}
30+
31+
try {
32+
new B;
33+
assert(false);
34+
} catch (e) {
35+
assert(e instanceof TypeError);
36+
}

0 commit comments

Comments
 (0)