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

Unified Diff: src/parser.cc

Issue 1019283002: [strong] Check constructor returns (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 4bcdfdbda7e2233fd25a710caea8f23d9d6d0510..99e66009251b66a05c0e104893408542c3e8e244 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -2707,6 +2707,7 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
// reported (underlining).
Expect(Token::RETURN, CHECK_OK);
Scanner::Location loc = scanner()->location();
+ function_state_->set_return_location(loc);
Token::Value tok = peek();
Statement* result;
@@ -2721,6 +2722,14 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
return_value = GetLiteralUndefined(position());
}
} else {
+ if (is_strong(language_mode()) &&
+ i::IsConstructor(function_state_->kind())) {
+ int pos = peek_position();
+ ReportMessageAt(Scanner::Location(pos, pos + 1),
+ "strong_constructor_return_value");
+ *ok = false;
+ return NULL;
+ }
return_value = ParseExpression(true, CHECK_OK);
}
ExpectSemicolon(CHECK_OK);

Powered by Google App Engine
This is Rietveld 408576698