diff --git a/src/lookup.cc b/src/lookup.cc index 256aa02d21cf..98aab68c6d94 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -308,6 +308,11 @@ void LookupIterator::PrepareTransitionToDataProperty( PropertyAttributes attributes, Object::StoreFromKeyed store_mode) { DCHECK(receiver.is_identical_to(GetStoreTarget())); if (state_ == TRANSITION) return; + + if (!IsElement() && name()->IsPrivate()) { + attributes = static_cast(attributes | DONT_ENUM); + } + DCHECK(state_ != LookupIterator::ACCESSOR || (GetAccessors()->IsAccessorInfo() && AccessorInfo::cast(*GetAccessors())->is_special_data_property())); @@ -442,6 +447,9 @@ void LookupIterator::TransitionToAccessorProperty( // handled via a trap. Adding properties to primitive values is not // observable. Handle receiver = GetStoreTarget(); + if (!IsElement() && name()->IsPrivate()) { + attributes = static_cast(attributes | DONT_ENUM); + } if (!IsElement() && !receiver->map()->is_dictionary_map()) { Handle old_map(receiver->map(), isolate_); diff --git a/src/property.h b/src/property.h index da015794df01..233233c5d4f9 100644 --- a/src/property.h +++ b/src/property.h @@ -36,6 +36,7 @@ class Descriptor BASE_EMBEDDED { void Init(Handle key, Handle value, PropertyDetails details) { DCHECK(key->IsUniqueName()); + DCHECK_IMPLIES(key->IsPrivate(), !details.IsEnumerable()); key_ = key; value_ = value; details_ = details; @@ -44,6 +45,7 @@ class Descriptor BASE_EMBEDDED { Descriptor(Handle key, Handle value, PropertyDetails details) : key_(key), value_(value), details_(details) { DCHECK(key->IsUniqueName()); + DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable()); } Descriptor(Handle key, Handle value, @@ -53,6 +55,7 @@ class Descriptor BASE_EMBEDDED { value_(value), details_(attributes, type, representation, field_index) { DCHECK(key->IsUniqueName()); + DCHECK_IMPLIES(key->IsPrivate(), !details_.IsEnumerable()); } friend class DescriptorArray; diff --git a/test/mjsunit/harmony/private.js b/test/mjsunit/harmony/private.js index 71b4377c57d8..cd65af1c7057 100644 --- a/test/mjsunit/harmony/private.js +++ b/test/mjsunit/harmony/private.js @@ -278,8 +278,8 @@ function TestKeyDescriptor(obj) { assertEquals(i|0, desc.value) assertTrue(desc.configurable) assertEquals(i % 2 == 0, desc.writable) - assertEquals(i % 2 == 0, desc.enumerable) - assertEquals(i % 2 == 0, + assertEquals(false, desc.enumerable) + assertEquals(false, Object.prototype.propertyIsEnumerable.call(obj, symbols[i])) } }