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

Unified Diff: src/contexts.cc

Issue 2352813002: Filter out synthetic variables from with scopes (Closed)
Patch Set: Created 4 years, 3 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 | « src/ast/scopes.cc ('k') | test/mjsunit/regress/regress-5405.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/contexts.cc
diff --git a/src/contexts.cc b/src/contexts.cc
index 3447b42f47dc32d3f37055fc36d9fa30f365ab43..71fe7a9b381c726266aff2560e0e7868ecb3394b 100644
--- a/src/contexts.cc
+++ b/src/contexts.cc
@@ -227,6 +227,11 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
(context->IsWithContext() && ((flags & SKIP_WITH_CONTEXT) == 0)) ||
context->IsFunctionContext() || context->IsBlockContext()) &&
context->extension_receiver() != nullptr) {
+ // A dynamic context will never bind "this" or a synthetic variable;
+ // scope analysis has already ensured that these are resolved
+ // statically.
+ DCHECK(!ScopeInfo::VariableIsSynthetic(*name));
+
Handle<JSReceiver> object(context->extension_receiver());
if (context->IsNativeContext()) {
@@ -261,20 +266,15 @@ Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags,
object->IsJSContextExtensionObject()) {
maybe = JSReceiver::GetOwnPropertyAttributes(object, name);
} else if (context->IsWithContext()) {
- // A with context will never bind "this".
- if (name->Equals(*isolate->factory()->this_string())) {
- maybe = Just(ABSENT);
+ LookupIterator it(object, name, object);
+ Maybe<bool> found = UnscopableLookup(&it);
+ if (found.IsNothing()) {
+ maybe = Nothing<PropertyAttributes>();
} else {
- LookupIterator it(object, name, object);
- Maybe<bool> found = UnscopableLookup(&it);
- if (found.IsNothing()) {
- maybe = Nothing<PropertyAttributes>();
- } else {
- // Luckily, consumers of |maybe| only care whether the property
- // was absent or not, so we can return a dummy |NONE| value
- // for its attributes when it was present.
- maybe = Just(found.FromJust() ? NONE : ABSENT);
- }
+ // Luckily, consumers of |maybe| only care whether the property
+ // was absent or not, so we can return a dummy |NONE| value
+ // for its attributes when it was present.
+ maybe = Just(found.FromJust() ? NONE : ABSENT);
}
} else {
maybe = JSReceiver::GetPropertyAttributes(object, name);
« no previous file with comments | « src/ast/scopes.cc ('k') | test/mjsunit/regress/regress-5405.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698