Commit bc18baf8 authored by verwaest's avatar verwaest Committed by Commit bot

Move the ReferenceError check out of SetPropertyInternal. SetSuperProperty cannot need this case.

BUG=

Review URL: https://codereview.chromium.org/1758733002

Cr-Commit-Position: refs/heads/master@{#34433}
parent 6d2c5fca
...@@ -4209,15 +4209,6 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it, ...@@ -4209,15 +4209,6 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
if (done) break; if (done) break;
} }
// If the receiver is the JSGlobalObject, the store was contextual. In case
// the property did not exist yet on the global object itself, we have to
// throw a reference error in strict mode. In sloppy mode, we continue.
if (it->GetReceiver()->IsJSGlobalObject() && is_strict(language_mode)) {
it->isolate()->Throw(*it->isolate()->factory()->NewReferenceError(
MessageTemplate::kNotDefined, it->name()));
return Nothing<bool>();
}
*found = false; *found = false;
return Nothing<bool>(); return Nothing<bool>();
} }
...@@ -4230,6 +4221,16 @@ Maybe<bool> Object::SetProperty(LookupIterator* it, Handle<Object> value, ...@@ -4230,6 +4221,16 @@ Maybe<bool> Object::SetProperty(LookupIterator* it, Handle<Object> value,
Maybe<bool> result = Maybe<bool> result =
SetPropertyInternal(it, value, language_mode, store_mode, &found); SetPropertyInternal(it, value, language_mode, store_mode, &found);
if (found) return result; if (found) return result;
// If the receiver is the JSGlobalObject, the store was contextual. In case
// the property did not exist yet on the global object itself, we have to
// throw a reference error in strict mode. In sloppy mode, we continue.
if (is_strict(language_mode) && it->GetReceiver()->IsJSGlobalObject()) {
it->isolate()->Throw(*it->isolate()->factory()->NewReferenceError(
MessageTemplate::kNotDefined, it->name()));
return Nothing<bool>();
}
ShouldThrow should_throw = ShouldThrow should_throw =
is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR; is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR;
return AddDataProperty(it, value, NONE, should_throw, store_mode); return AddDataProperty(it, value, NONE, should_throw, store_mode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment