[parser] Allow same-named labelled blocks in if/else statements

Bug: chromium:917215
Change-Id: Ie2127953a8ce3d6da4feb3478039ba318774e21d
Reviewed-on: https://chromium-review.googlesource.com/c/1404176
Reviewed-by: Georg Neis <neis@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58755}
This commit is contained in:
Adam Klein 2019-01-10 14:53:48 -08:00 committed by Commit Bot
parent 7ebbe03e08
commit 469754d01c
2 changed files with 13 additions and 1 deletions

View File

@ -4777,7 +4777,13 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseIfStatement(
StatementT then_statement = impl()->NullStatement();
{
SourceRangeScope range_scope(scanner(), &then_range);
then_statement = ParseScopedStatement(labels);
// Make a copy of {labels} to avoid conflicts with any
// labels that may be applied to the else clause below.
auto labels_copy =
labels == nullptr
? labels
: new (zone()) ZonePtrList<const AstRawString>(*labels, zone());
then_statement = ParseScopedStatement(labels_copy);
}
StatementT else_statement = impl()->NullStatement();

View File

@ -0,0 +1,6 @@
// 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.
a: if (true) b: { break a; break b; }
else b: { break a; break b; }