Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 307e825216e63c4c492681f81652202ea86565be..8b44eceaf006dc61dd0fda63f456956b88a11e94 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -9546,8 +9546,12 @@ MaybeObject* JSObject::SetDictionaryElement(uint32_t index, |
return SetElementWithCallback(element, index, value, this, strict_mode); |
} else { |
dictionary->UpdateMaxNumberKey(index); |
- // If put fails in strict mode, throw an exception. |
- if (!dictionary->ValueAtPut(entry, value) && strict_mode == kStrictMode) { |
+ // If a value has not been initialized we allow writing to it even if it |
+ // is read-only (a declared const that has not been initialized). |
+ if (!dictionary->DetailsAt(entry).IsReadOnly() || |
+ dictionary->ValueAt(entry)->IsTheHole()) { |
+ dictionary->ValueAtPut(entry, value); |
+ } else if (strict_mode == kStrictMode) { |
Handle<Object> holder(this); |
Handle<Object> number = isolate->factory()->NewNumberFromUint(index); |
Handle<Object> args[2] = { number, holder }; |