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 417cf0fc7..acb05f525 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c @@ -827,6 +827,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */ JERRY_ASSERT (start <= len && end <= len); + bool use_fast_path = ecma_op_object_is_fast_array (obj_p); #if ENABLED (JERRY_ES2015) ecma_value_t new_array = ecma_op_array_species_create (obj_p, 0); @@ -834,6 +835,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */ { return new_array; } + use_fast_path &= ecma_op_object_is_fast_array (ecma_get_object_from_value (new_array)); #else /* !ENABLED (JERRY_ES2015) */ ecma_value_t new_array = ecma_op_create_array_object (NULL, 0, false); JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (new_array)); @@ -844,7 +846,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */ /* 9. */ uint32_t n = 0; - if (ecma_op_object_is_fast_array (obj_p)) + if (use_fast_path) { ecma_extended_object_t *ext_from_obj_p = (ecma_extended_object_t *) obj_p; diff --git a/tests/jerry/es2015/regression-test-issue-3459.js b/tests/jerry/es2015/regression-test-issue-3459.js new file mode 100644 index 000000000..7bb686e36 --- /dev/null +++ b/tests/jerry/es2015/regression-test-issue-3459.js @@ -0,0 +1,21 @@ +// 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. + +class MyOtherArray {} + +class MyNonArray extends Array { + static [Symbol.species] () {} +} + +(() => MyNonArray)().prototype.slice.call(new MyNonArray((0) === 1))