Commit 58bbc6bf authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[parser] Check if async function before throwing error

This changes the DCHECK (which could correctly fail) to be part of the
conditional that checks if we're in an async function.

Bug: chromium:751789
Change-Id: I3b8c1239ac93190055622c41fa1122e83b69d255
Reviewed-on: https://chromium-review.googlesource.com/607356Reviewed-by: 's avatarDaniel Ehrenberg <littledan@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47261}
parent 35f149e1
......@@ -713,8 +713,7 @@ class ParserBase {
}
*ok = false;
if (current == Token::AWAIT) {
DCHECK(!is_async_function());
if (current == Token::AWAIT && !is_async_function()) {
ReportMessageAt(current_location,
MessageTemplate::kAwaitNotInAsyncFunction, kSyntaxError);
return;
......
// Copyright 2017 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.
assertThrows(() => eval('async A=>{s.await i}'));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment