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

Unified Diff: src/preparser.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/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 914f1192df651d0a578d9700edb23a03ad9cbdbe..5a6a094f6af52b7ba025e9d4ff9c0450499497f7 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -613,6 +613,7 @@ PreParser::Statement PreParser::ParseReturnStatement(bool* ok) {
// reporting any errors on it, because of the way errors are
// reported (underlining).
Expect(Token::RETURN, CHECK_OK);
+ function_state_->set_return_location(scanner()->location());
// An ECMAScript program is considered syntactically incorrect if it
// contains a return statement that is not within the body of a
@@ -624,6 +625,14 @@ PreParser::Statement PreParser::ParseReturnStatement(bool* ok) {
tok != Token::SEMICOLON &&
tok != Token::RBRACE &&
tok != Token::EOS) {
+ 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 Statement::Default();
+ }
ParseExpression(true, CHECK_OK);
}
ExpectSemicolon(CHECK_OK);

Powered by Google App Engine
This is Rietveld 408576698