Native try-catch syntax parsing should not crash.

R=littledan@chromium.org
BUG=chromium:630559

Review-Url: https://codereview.chromium.org/2176613002
Cr-Commit-Position: refs/heads/master@{#37996}
This commit is contained in:
yangguo 2016-07-24 22:32:11 -07:00 committed by Commit bot
parent e3e347b85c
commit 986814218b
2 changed files with 17 additions and 10 deletions

View File

@ -2993,18 +2993,18 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
}
Token::Value tok = peek();
bool catch_for_promise_reject = false;
if (allow_natives() && tok == Token::MOD) {
Consume(Token::MOD);
catch_for_promise_reject = true;
tok = peek();
}
if (tok != Token::CATCH && tok != Token::FINALLY) {
if (allow_natives() && tok == Token::MOD) {
Consume(Token::MOD);
catch_for_promise_reject = true;
tok = peek();
DCHECK_EQ(Token::CATCH, tok);
} else {
ReportMessage(MessageTemplate::kNoCatchOrFinally);
*ok = false;
return NULL;
}
ReportMessage(MessageTemplate::kNoCatchOrFinally);
*ok = false;
return NULL;
}
Scope* catch_scope = NULL;

View File

@ -0,0 +1,7 @@
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
assertThrows("try{}%");