Skip to content

Commit

Permalink
[parsing] Fix bug in rewriter concerning a breakable try-finally.
Browse files Browse the repository at this point in the history
R=adamk@chromium.org

Bug: chromium:787698
Change-Id: I873debe61b152a9e88ce22d95a69f27eab2d0f55
Reviewed-on: https://chromium-review.googlesource.com/787473
Reviewed-by: Marja Hölttä <marja@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49653}
  • Loading branch information
GeorgNeis authored and Commit Bot committed Nov 28, 2017
1 parent e797f9f commit aa7d143
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/parsing/rewriter.cc
Expand Up @@ -263,6 +263,9 @@ void Processor::VisitTryFinallyStatement(TryFinallyStatement* node) {
0, factory()->NewExpressionStatement(save, kNoSourcePosition), zone());
node->finally_block()->statements()->Add(
factory()->NewExpressionStatement(restore, kNoSourcePosition), zone());
// We can't tell whether the finally-block is guaranteed to set .result, so
// reset is_set_ before visiting the try-block.
is_set_ = false;
}
Visit(node->try_block());
node->set_try_block(replacement_->AsBlock());
Expand Down
7 changes: 7 additions & 0 deletions test/mjsunit/es6/completion.js
Expand Up @@ -169,3 +169,10 @@ assertUndef(eval(
assertUndef(eval("1; try{2; throwOnReturn();} catch(e){}"));
assertUndef(eval("1; twoFunc();"));
assertEquals(2, eval("1; with ( { a: 0 } ) { 2; }"));

// https://bugs.chromium.org/p/chromium/issues/detail?id=787698
assertEquals(42, eval("try {42} catch (_) {} finally {}"));
assertEquals(42, eval("try {42} catch (_) {} finally {43}"));
assertEquals(42, eval("foo: try {42} catch (_) {} finally {}"));
assertEquals(42, eval("foo: try {42} catch (_) {} finally {43}"));
assertEquals(43, eval("foo: try {42} catch (_) {} finally {43; break foo}"));

0 comments on commit aa7d143

Please sign in to comment.