[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/+/1781057 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#63542}
This commit is contained in:
parent
bf78435b2c
commit
afca89f848
@ -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 () => ...
|
||||
|
8
test/mjsunit/regress/regress-crbug-997320.js
Normal file
8
test/mjsunit/regress/regress-crbug-997320.js
Normal file
@ -0,0 +1,8 @@
|
||||
// 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) => {};
|
Loading…
Reference in New Issue
Block a user