Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Unified Diff: src/objects.cc

Issue 1758733002: Move the ReferenceError check out of SetPropertyInternal. SetSuperProperty cannot need this case. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index f3d492955bfab448238de125ab7e519fc497085c..12b206cce9fb863d23bc9e611126ea5c0a1cb70f 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -4209,15 +4209,6 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
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;
return Nothing<bool>();
}
@@ -4230,6 +4221,16 @@ Maybe<bool> Object::SetProperty(LookupIterator* it, Handle<Object> value,
Maybe<bool> result =
SetPropertyInternal(it, value, language_mode, store_mode, &found);
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 =
is_sloppy(language_mode) ? DONT_THROW : THROW_ON_ERROR;
return AddDataProperty(it, value, NONE, should_throw, store_mode);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698