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

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: . Created 5 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 | « src/globals.h ('k') | src/runtime/runtime-debug.cc » ('j') | src/scopes.cc » ('J')
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 aa6ee8ccb6c67a3d210a39b18e97a31f9808ea32..49a08ce9c5a0687b90e0e121df1133cc0cb86a6c 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1809,6 +1809,7 @@ Variable* Parser::Declare(Declaration* declaration, bool resolve, bool* ok) {
if (declaration_scope->is_function_scope() ||
declaration_scope->is_strict_eval_scope() ||
declaration_scope->is_block_scope() ||
+ declaration_scope->is_class_scope() ||
declaration_scope->is_module_scope() ||
declaration_scope->is_script_scope()) {
// Declare the variable in the declaration scope.
@@ -4093,8 +4094,8 @@ ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
return NULL;
}
- Scope* block_scope = NewScope(scope_, BLOCK_SCOPE);
- BlockState block_state(&scope_, block_scope);
+ Scope* class_scope = NewScope(scope_, CLASS_SCOPE);
+ BlockState block_state(&scope_, class_scope);
scope_->SetLanguageMode(
static_cast<LanguageMode>(scope_->language_mode() | STRICT_BIT));
scope_->SetScopeName(name);
@@ -4103,16 +4104,16 @@ ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
if (name != NULL) {
proxy = NewUnresolved(name, CONST);
Declaration* declaration =
- factory()->NewVariableDeclaration(proxy, CONST, block_scope, pos);
+ factory()->NewVariableDeclaration(proxy, CONST, class_scope, pos);
Declare(declaration, true, CHECK_OK);
}
Expression* extends = NULL;
if (Check(Token::EXTENDS)) {
- block_scope->set_start_position(scanner()->location().end_pos);
+ class_scope->set_start_position(scanner()->location().end_pos);
extends = ParseLeftHandSideExpression(CHECK_OK);
} else {
- block_scope->set_start_position(scanner()->location().end_pos);
+ class_scope->set_start_position(scanner()->location().end_pos);
}
@@ -4153,19 +4154,21 @@ ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
if (constructor == NULL) {
constructor =
- DefaultConstructor(extends != NULL, block_scope, pos, end_pos);
+ DefaultConstructor(extends != NULL, class_scope, pos, end_pos);
}
- block_scope->set_end_position(end_pos);
- block_scope = block_scope->FinalizeBlockScope();
+ class_scope->set_end_position(end_pos);
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 class scope will be empty).
arv (Not doing code reviews) 2015/03/03 15:36:28 Unnamed classed do not need to have a scope.
marja 2015/03/03 15:52:14 Clarification: this comment was b/c some places re
+ DCHECK(class_scope->num_var_or_const() == 0);
+ class_scope = nullptr;
}
- return factory()->NewClassLiteral(name, block_scope, proxy, extends,
+ return factory()->NewClassLiteral(name, class_scope, proxy, extends,
constructor, properties, pos, end_pos);
}
« no previous file with comments | « src/globals.h ('k') | src/runtime/runtime-debug.cc » ('j') | src/scopes.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698