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

Unified Diff: src/preparser.cc

Issue 1314203002: [strong] Class constructor bodies cannot contain "use strong" directive (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: formatting Created 5 years, 4 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
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 7e75e78ef9c2e0753c26e6f8bf9f5303ddc02f70..48f228d97e74a2abc8e3930d59bd5b3de84883dd 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -262,6 +262,14 @@ void PreParser::ParseStatementList(int end_token, bool* ok,
} else if (use_strong_found) {
scope_->SetLanguageMode(static_cast<LanguageMode>(
scope_->language_mode() | STRONG));
+ if (i::IsConstructor(function_state_->kind())) {
+ // "use strong" cannot occur in a class constructor body, to avoid
+ // unintuitive strong class object semantics.
+ PreParserTraits::ReportMessageAt(
+ token_loc, MessageTemplate::kStrongConstructorDirective);
+ *ok = false;
+ return;
+ }
} else if (!statement.IsStringLiteral()) {
directive_prologue = false;
}

Powered by Google App Engine
This is Rietveld 408576698