Index: src/api-natives.cc |
diff --git a/src/api-natives.cc b/src/api-natives.cc |
index 74518447ea329a61a703cd66fa459d5ca2b1ee4f..71a039f35ea8d4d312e43a398392630190618163 100644 |
--- a/src/api-natives.cc |
+++ b/src/api-natives.cc |
@@ -80,24 +80,32 @@ |
ASSIGN_RETURN_ON_EXCEPTION(isolate, value, |
Instantiate(isolate, prop_data, key), Object); |
- uint32_t index = 0; |
- LookupIterator::Configuration c = LookupIterator::OWN_SKIP_INTERCEPTOR; |
- LookupIterator it = key->AsArrayIndex(&index) |
- ? LookupIterator(isolate, object, index, c) |
- : LookupIterator(object, key, c); |
- |
#ifdef DEBUG |
- Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
- DCHECK(maybe.IsJust()); |
- if (it.IsFound()) { |
+ bool duplicate; |
+ if (key->IsName()) { |
+ LookupIterator it(object, Handle<Name>::cast(key), |
+ LookupIterator::OWN_SKIP_INTERCEPTOR); |
+ Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); |
+ DCHECK(maybe.IsJust()); |
+ duplicate = it.IsFound(); |
+ } else { |
+ uint32_t index = 0; |
+ key->ToArrayIndex(&index); |
+ Maybe<bool> maybe = JSReceiver::HasOwnElement(object, index); |
+ if (!maybe.IsJust()) return MaybeHandle<Object>(); |
+ duplicate = maybe.FromJust(); |
+ } |
+ if (duplicate) { |
THROW_NEW_ERROR( |
isolate, NewTypeError(MessageTemplate::kDuplicateTemplateProperty, key), |
Object); |
} |
#endif |
- return Object::AddDataProperty(&it, value, attributes, STRICT, |
- Object::CERTAINLY_NOT_STORE_FROM_KEYED); |
+ RETURN_ON_EXCEPTION( |
+ isolate, Runtime::DefineObjectProperty(object, key, value, attributes), |
+ Object); |
+ return object; |
} |