From 0bb4626ddb36e80b4682810db9a6a9b0123bfdab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csaba=20Osztrogon=C3=A1c?= Date: Wed, 12 Aug 2020 16:35:27 +0200 Subject: [PATCH] Fix Array.prototype.slice, splice and map builtin methods (#4122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CreateDataPropertyOrThrow is introduced in ES2015, and these methods should use it to throw TypeError exception if the requested property update cannot be performed. JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu --- .../ecma-builtin-array-prototype.c | 21 ++++++++++++++++--- tests/test262-esnext-excludelist.xml | 6 ------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c index f21df35c2..562708779 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c @@ -948,10 +948,15 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */ { /* 10.c.ii */ ecma_value_t put_comp; +#if ENABLED (JERRY_ESNEXT) + const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW; +#else /* !ENABLED (JERRY_ESNEXT) */ + const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE; +#endif /* ENABLED (JERRY_ESNEXT) */ put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, n, get_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); + prop_flags); ecma_free_value (get_value); #if ENABLED (JERRY_ESNEXT) @@ -1345,10 +1350,15 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu { /* 9.c.ii */ ecma_value_t put_comp; +#if ENABLED (JERRY_ESNEXT) + const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW; +#else /* !ENABLED (JERRY_ESNEXT) */ + const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE; +#endif /* ENABLED (JERRY_ESNEXT) */ put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, k, get_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); + prop_flags); ecma_free_value (get_value); #if ENABLED (JERRY_ESNEXT) if (ECMA_IS_VALUE_ERROR (put_comp)) @@ -2007,10 +2017,15 @@ ecma_builtin_array_prototype_object_map (ecma_value_t arg1, /**< callbackfn */ /* 8.c.iii */ ecma_value_t put_comp; +#if ENABLED (JERRY_ESNEXT) + const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW; +#else /* !ENABLED (JERRY_ESNEXT) */ + const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE; +#endif /* ENABLED (JERRY_ESNEXT) */ put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, index, mapped_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); + prop_flags); ecma_free_value (mapped_value); ecma_free_value (current_value); diff --git a/tests/test262-esnext-excludelist.xml b/tests/test262-esnext-excludelist.xml index 453f92e4c..4d6f5f04a 100644 --- a/tests/test262-esnext-excludelist.xml +++ b/tests/test262-esnext-excludelist.xml @@ -194,12 +194,8 @@ - - - - @@ -208,8 +204,6 @@ - -