From b749c4c267153edc93db7bdb774e9781dbd96aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20G=C3=A1l?= Date: Tue, 4 Aug 2020 16:52:08 +0200 Subject: [PATCH] Allow error reporting during property creation in Array.prototype.filter (#4091) In case of ES.next the Array.prototype.filter should raise an error if the property on the target array's data property creation fails. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com --- .../ecma/builtin-objects/ecma-builtin-array-prototype.c | 8 +++++++- tests/test262-esnext-excludelist.xml | 2 -- 2 files changed, 7 insertions(+), 3 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 689aeb5e3..80e8f2b05 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c @@ -2058,9 +2058,15 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t arg1, /**< callbackfn * { return new_array; } + + /* ES11: 22.1.3.7. 7.c.iii.1 */ + const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW; #else /* !ENABLED (JERRY_ESNEXT) */ ecma_value_t new_array = ecma_op_create_array_object (NULL, 0, false); JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (new_array)); + + /* ES5.1: 15.4.4.20. 9.c.iii.1 */ + const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE; #endif /* ENABLED (JERRY_ESNEXT) */ ecma_object_t *new_array_p = ecma_get_object_from_value (new_array); @@ -2108,7 +2114,7 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t arg1, /**< callbackfn * put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, new_array_index, get_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); + prop_flags); #if ENABLED (JERRY_ESNEXT) if (ECMA_IS_VALUE_ERROR (put_comp)) { diff --git a/tests/test262-esnext-excludelist.xml b/tests/test262-esnext-excludelist.xml index c5000a4e9..5f3a4a7b4 100644 --- a/tests/test262-esnext-excludelist.xml +++ b/tests/test262-esnext-excludelist.xml @@ -167,8 +167,6 @@ - -