Index: src/parsing/parser.cc |
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc |
index 3cae66e2693f39c832686aadd81809b7ef8d56cc..8b69029972543e2e4c35bf2904474e4ee3af3fa3 100644 |
--- a/src/parsing/parser.cc |
+++ b/src/parsing/parser.cc |
@@ -2983,10 +2983,18 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
} |
Token::Value tok = peek(); |
+ bool catch_for_promise_reject = false; |
if (tok != Token::CATCH && tok != Token::FINALLY) { |
- ReportMessage(MessageTemplate::kNoCatchOrFinally); |
- *ok = false; |
- return NULL; |
+ if (allow_natives() && tok == Token::MOD) { |
+ Consume(Token::MOD); |
+ catch_for_promise_reject = true; |
+ tok = peek(); |
+ DCHECK_EQ(Token::CATCH, tok); |
Dan Ehrenberg
2016/07/21 21:07:33
Nit: I wonder if we should use CHECK here; if it w
|
+ } else { |
+ ReportMessage(MessageTemplate::kNoCatchOrFinally); |
+ *ok = false; |
+ return NULL; |
+ } |
} |
Scope* catch_scope = NULL; |
@@ -3104,8 +3112,17 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
if (catch_block != NULL && finally_block != NULL) { |
// If we have both, create an inner try/catch. |
DCHECK(catch_scope != NULL && catch_variable != NULL); |
- TryCatchStatement* statement = factory()->NewTryCatchStatement( |
- try_block, catch_scope, catch_variable, catch_block, kNoSourcePosition); |
+ TryCatchStatement* statement; |
+ if (catch_for_promise_reject) { |
+ statement = factory()->NewTryCatchStatementForPromiseReject( |
+ try_block, catch_scope, catch_variable, catch_block, |
+ kNoSourcePosition); |
+ } else { |
+ statement = factory()->NewTryCatchStatement(try_block, catch_scope, |
+ catch_variable, catch_block, |
+ kNoSourcePosition); |
+ } |
+ |
try_block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition); |
try_block->statements()->Add(statement, zone()); |
catch_block = NULL; // Clear to indicate it's been handled. |