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

Unified Diff: src/preparser.h

Issue 1244423003: [es6] Fix function context check for super and new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment; added test for super calls Created 5 years, 5 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 | src/scopes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 8680f88bf940ff208f9b419ca90d048e98917374..5ed1cd6bc4f911564df2764bf17b7cdab63e2510 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -3504,13 +3504,7 @@ ParserBase<Traits>::ParseSuperExpression(bool is_new,
int pos = position();
Expect(Token::SUPER, CHECK_OK);
- Scope* scope = scope_->DeclarationScope();
- while (scope->is_eval_scope() || scope->is_arrow_scope()) {
- scope = scope->outer_scope();
- DCHECK_NOT_NULL(scope);
- scope = scope->DeclarationScope();
- }
-
+ Scope* scope = scope_->ReceiverScope();
FunctionKind kind = scope->function_kind();
if (IsConciseMethod(kind) || IsAccessorFunction(kind) ||
i::IsConstructor(kind)) {
@@ -3548,14 +3542,7 @@ ParserBase<Traits>::ParseNewTargetExpression(bool* ok) {
Consume(Token::PERIOD);
ExpectContextualKeyword(CStrVector("target"), CHECK_OK);
- Scope* scope = scope_->DeclarationScope();
- while (scope->is_eval_scope() || scope->is_arrow_scope()) {
- scope = scope->outer_scope();
- DCHECK_NOT_NULL(scope);
- scope = scope->DeclarationScope();
- }
-
- if (!scope->is_function_scope()) {
+ if (!scope_->ReceiverScope()->is_function_scope()) {
ReportMessageAt(scanner()->location(),
MessageTemplate::kUnexpectedNewTarget);
*ok = false;
« no previous file with comments | « no previous file | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698