diff --git a/src/parsing/rewriter.cc b/src/parsing/rewriter.cc index 37bf66b320ae..c31d0ea21dd6 100644 --- a/src/parsing/rewriter.cc +++ b/src/parsing/rewriter.cc @@ -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()); diff --git a/test/mjsunit/es6/completion.js b/test/mjsunit/es6/completion.js index b9d93f41c098..d88fcd054f39 100644 --- a/test/mjsunit/es6/completion.js +++ b/test/mjsunit/es6/completion.js @@ -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}"));