Commit aa7d1438 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[parsing] Fix bug in rewriter concerning a breakable try-finally.

R=adamk@chromium.org

Bug: chromium:787698
Change-Id: I873debe61b152a9e88ce22d95a69f27eab2d0f55
Reviewed-on: https://chromium-review.googlesource.com/787473Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49653}
parent e797f9fb
......@@ -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());
......
......@@ -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}"));
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