Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions jerry-core/ecma/operations/ecma-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -2061,8 +2061,6 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
ecma_collection_t *ret_p = ecma_new_collection ();
ecma_collection_t *skipped_non_enumerable_p = ecma_new_collection ();

const ecma_object_type_t type = ecma_get_object_type (obj_p);
const bool obj_is_builtin = ecma_get_object_is_builtin (obj_p);
const bool is_enumerable_only = (opts & ECMA_LIST_ENUMERABLE) != 0;
const bool is_array_indices_only = (opts & ECMA_LIST_ARRAY_INDICES) != 0;
const bool is_with_prototype_chain = (opts & ECMA_LIST_PROTOTYPE) != 0;
Expand All @@ -2077,10 +2075,10 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */

memset (names_hashes_bitmap, 0, names_hashes_bitmap_size * sizeof (names_hashes_bitmap[0]));

ecma_object_t *prototype_chain_iter_p = obj_p;

while (true)
{
const ecma_object_type_t type = ecma_get_object_type (obj_p);
const bool obj_is_builtin = ecma_get_object_is_builtin (obj_p);
ecma_length_t string_named_properties_count = 0;
ecma_length_t array_index_named_properties_count = 0;
#if ENABLED (JERRY_ES2015)
Expand Down Expand Up @@ -2232,14 +2230,14 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
}
}

jmem_cpointer_t prop_iter_cp = prototype_chain_iter_p->u1.property_list_cp;
jmem_cpointer_t prop_iter_cp = obj_p->u1.property_list_cp;

if (ecma_op_object_is_fast_array (prototype_chain_iter_p) && prop_iter_cp != JMEM_CP_NULL)
if (ecma_op_object_is_fast_array (obj_p) && prop_iter_cp != JMEM_CP_NULL)
{
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) prototype_chain_iter_p;
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;

uint32_t length = ext_obj_p->u.array.length;
array_index_named_properties_count = length - ecma_fast_array_get_hole_count (prototype_chain_iter_p);
array_index_named_properties_count = length - ecma_fast_array_get_hole_count (obj_p);

ecma_value_t *values_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, prop_iter_cp);

Expand Down Expand Up @@ -2571,13 +2569,12 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */

JMEM_FINALIZE_LOCAL_ARRAY (names_p);

if (!is_with_prototype_chain || prototype_chain_iter_p->u2.prototype_cp == JMEM_CP_NULL)
if (!is_with_prototype_chain || obj_p->u2.prototype_cp == JMEM_CP_NULL)
{
break;
}

prototype_chain_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t,
prototype_chain_iter_p->u2.prototype_cp);
obj_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, obj_p->u2.prototype_cp);
}

ecma_collection_free (skipped_non_enumerable_p);
Expand Down
32 changes: 32 additions & 0 deletions tests/jerry/es2015/regression-test-issue-3784.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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 = ['0', '1', '2', '3', '4', '5'];
var actual = [];

var v1 = typeof 13.37;
var v3 = Object(v1);
var v5 = [13.37,13.37];
var v6 = [v5];
v3.__proto__ = v6;

for (var v7 in v3) {
actual.push(v7);
}

assert(actual.length === expected.length);

for (var i = 0; i < actual.length; i++) {
assert(actual[i] === expected[i]);
}