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

Unified Diff: src/preparser.cc

Issue 1002253002: [strong] Check super constructor calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Should be ReferenceError 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/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 76f4625f3c69e647057e5aeef6cb1bf8514dbe26..ee6c900bcec54b59100e929d4da79353b570d1d9 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -193,8 +193,19 @@ void PreParser::ParseStatementList(int end_token, bool* ok) {
if (directive_prologue && peek() != Token::STRING) {
directive_prologue = false;
}
+ Token::Value token = peek();
+ Scanner::Location old_super_loc = function_state_->super_call_location();
Statement statement = ParseStatementListItem(ok);
if (!*ok) return;
+ Scanner::Location super_loc = function_state_->super_call_location();
+ if (is_strong(language_mode()) &&
+ i::IsConstructor(function_state_->kind()) &&
+ !old_super_loc.IsValid() && super_loc.IsValid() &&
+ token != Token::SUPER) {
+ ReportMessageAt(super_loc, "strong_super_call_nested");
+ *ok = false;
+ return;
+ }
if (directive_prologue) {
if (statement.IsUseStrictLiteral()) {
scope_->SetLanguageMode(
@@ -938,6 +949,15 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
CheckStrictOctalLiteral(start_position, end_position, CHECK_OK);
}
+ if (is_strong(language_mode()) && IsSubclassConstructor(kind)) {
+ if (!function_state.super_call_location().IsValid()) {
+ ReportMessageAt(function_name_location, "strong_super_call_missing",
+ kReferenceError);
+ *ok = false;
+ return Expression::Default();
+ }
+ }
+
return Expression::Default();
}
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698