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

Unified Diff: src/parser.cc

Issue 968263002: [strong] Fix scoping related errors for methods. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: code review (arv, rossberg) Created 5 years, 9 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/objects.h ('k') | src/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 1345a790eb6258d0d0d6d6bdc5bfb95778ac42e8..2b5d5f2dbfc28c6b1b6965b32a04467d9f7b7a34 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -4100,7 +4100,11 @@ ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
return NULL;
}
+ // Create a block scope which is additionally tagged as class scope; this is
+ // important for resolving variable references to the class name in the strong
+ // mode.
Scope* block_scope = NewScope(scope_, BLOCK_SCOPE);
+ block_scope->tag_as_class_scope();
BlockState block_state(&scope_, block_scope);
scope_->SetLanguageMode(
static_cast<LanguageMode>(scope_->language_mode() | STRICT_BIT));
@@ -4164,12 +4168,14 @@ ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
}
block_scope->set_end_position(end_pos);
- block_scope = block_scope->FinalizeBlockScope();
if (name != NULL) {
DCHECK_NOT_NULL(proxy);
- DCHECK_NOT_NULL(block_scope);
proxy->var()->set_initializer_position(end_pos);
+ } else {
+ // Unnamed classes should not have scopes (the scope will be empty).
+ DCHECK_EQ(block_scope->num_var_or_const(), 0);
+ block_scope = nullptr;
}
return factory()->NewClassLiteral(name, block_scope, proxy, extends,
« no previous file with comments | « src/objects.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698