From 6ef0a0e07ed31abfe72fb01b2a70081c4d314a49 Mon Sep 17 00:00:00 2001 From: Robert Fancsik Date: Thu, 12 Mar 2020 12:45:53 +0100 Subject: [PATCH] Fix the lazy listing of builtin property names (#3607) This patch fixes #3606. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu --- jerry-core/ecma/builtin-objects/ecma-builtins.c | 13 +++++++++++-- jerry-core/ecma/operations/ecma-objects.c | 1 + .../jerry/es2015/regression-test-issue-3606.js | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/jerry/es2015/regression-test-issue-3606.js diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.c b/jerry-core/ecma/builtin-objects/ecma-builtins.c index 68e80c175..197eab2c1 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.c @@ -962,7 +962,7 @@ ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in uint32_t *bitset_p = built_in_props_p->instantiated_bitset; ecma_collection_t *for_non_enumerable_p = (separate_enumerable ? non_enum_collection_p - : main_collection_p); + : main_collection_p); while (curr_property_p->magic_string_id != LIT_MAGIC_STRING__COUNT) { @@ -995,7 +995,16 @@ ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in { ecma_value_t name = ecma_make_magic_string_value ((lit_magic_string_id_t) curr_property_p->magic_string_id); - ecma_collection_push_back (for_non_enumerable_p, name); +#if ENABLED (JERRY_ES2015) + if (curr_property_p->attributes & ECMA_PROPERTY_FLAG_ENUMERABLE) + { + ecma_collection_push_back (main_collection_p, name); + } + else +#endif /* ENABLED (JERRY_ES2015) */ + { + ecma_collection_push_back (for_non_enumerable_p, name); + } } curr_property_p++; diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index 42ae0e4a8..9629d3a99 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -2438,6 +2438,7 @@ ecma_object_check_class_name_is_object (ecma_object_t *obj_p) /**< object */ #endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */ #endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */ #if ENABLED (JERRY_ES2015) + || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_ARRAY_PROTOTYPE_UNSCOPABLES) || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_ARRAY_ITERATOR_PROTOTYPE) || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_ITERATOR_PROTOTYPE) || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_STRING_ITERATOR_PROTOTYPE) diff --git a/tests/jerry/es2015/regression-test-issue-3606.js b/tests/jerry/es2015/regression-test-issue-3606.js new file mode 100644 index 000000000..bcd1466eb --- /dev/null +++ b/tests/jerry/es2015/regression-test-issue-3606.js @@ -0,0 +1,17 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// 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. + + +var expected = '{"values":true,"keys":true,"findIndex":true,"find":true,"fill":true,"entries":true,"copyWithin":true}'; +assert(JSON.stringify(Array.prototype[Symbol.unscopables]) === expected);