Commit afca89f8 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[parser] Improve hole check elision in async arrow funcs

Use the position of commas in async arrow expressions to mark the
initializer position of any parameters that might have been set in the
preceding parameter.

This extends https://chromium-review.googlesource.com/c/v8/v8/+/1710671
to async arrow heads.

Bug: v8:8510, chromium:997320
Change-Id: I98e0ac817c7f53fbf1dced98fb6891a386ee7803
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1781057Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63542}
parent bf78435b
......@@ -2566,6 +2566,7 @@ void ParserBase<Impl>::ParseArguments(
Consume(Token::LPAREN);
AccumulationScope accumulation_scope(expression_scope());
int variable_index = 0;
while (peek() != Token::RPAREN) {
int start_pos = peek_position();
bool is_spread = Check(Token::ELLIPSIS);
......@@ -2593,6 +2594,10 @@ void ParserBase<Impl>::ParseArguments(
argument = factory()->NewSpread(argument, start_pos, expr_pos);
}
args->Add(argument);
variable_index =
expression_scope()->SetInitializers(variable_index, peek_position());
if (!Check(Token::COMMA)) break;
}
......@@ -3123,7 +3128,6 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) {
ParseArguments(&args, &has_spread, kMaybeArrowHead);
if (V8_LIKELY(peek() == Token::ARROW)) {
fni_.RemoveAsyncKeywordFromEnd();
expression_scope()->SetInitializers(0, peek_position());
next_arrow_function_info_.scope = maybe_arrow.ValidateAndCreateScope();
scope_snapshot.Reparent(next_arrow_function_info_.scope);
// async () => ...
......
// Copyright 2019 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: --no-lazy --stress-lazy-source-positions
// Flags: --enable-lazy-source-positions
async(a, b = a) => {};
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