Commit 67f1969a authored by neis's avatar neis Committed by Commit bot

[parsing] Fix bug in completion value of try-finally.

R=adamk@chromium.org, verwaest@chromium.org
BUG=v8:5698

Review-Url: https://codereview.chromium.org/2537413003
Cr-Commit-Position: refs/heads/master@{#41495}
parent 0e43c392
......@@ -243,7 +243,6 @@ void Processor::VisitTryFinallyStatement(TryFinallyStatement* node) {
// Only rewrite finally if it could contain 'break' or 'continue'. Always
// rewrite try.
if (breakable_) {
bool set_after = is_set_;
// Only set result before a 'break' or 'continue'.
is_set_ = true;
Visit(node->finally_block());
......@@ -265,7 +264,6 @@ void Processor::VisitTryFinallyStatement(TryFinallyStatement* node) {
0, factory()->NewExpressionStatement(save, kNoSourcePosition), zone());
node->finally_block()->statements()->Add(
factory()->NewExpressionStatement(restore, kNoSourcePosition), zone());
is_set_ = set_after;
}
Visit(node->try_block());
node->set_try_block(replacement_->AsBlock());
......
......@@ -107,9 +107,22 @@ assertEquals(undefined, eval(
'var b = 1; ' +
'outer: while (1) { while (1) { if (b--) 42; else break outer; }; 666 }'));
// The following is not what ES6 says, but see ES bug 4540.
assertUndef(eval('42; switch (0) { case 0: 1; if (true) break; }')); // ES5: 1
assertUndef(eval('a: while(true) { do { 0 } while(false); switch(1) { case 0: 1; case 1: break a; }; 0 }'));
assertUndef(eval('a: while(true) { do { 0 } while(false); try {} finally { break a }; 0 }'));
assertUndef(eval('a: while(true) { b: while(true) { 0; break b; }; switch(1) { case 1: break a; }; 2 }'));
assertUndef(eval('a: while(true) { b: while(true) { 0; break b; }; while (true) { break a; }; 2 }'));
assertUndef(eval('while (true) { 20; a:{ break a; } with ({}) break; 30; }'));
assertEquals(42, eval('a: while(true) { switch(0) { case 0: 42; case 1: break a; }; 33 }'));
assertUndef(eval(
'for (var i = 0; i < 2; ++i) { if (i) { try {} finally { break; } } 0; }'
));
assertUndef(eval(
'for (var i = 0; i < 2; ++i) { if (i) { try {} finally { continue; } } 0; }'
));
////////////////////////////////////////////////////////////////////////////////
......@@ -146,10 +159,3 @@ assertUndef(eval(
assertUndef(eval("1; try{2; throwOnReturn();} catch(e){}"));
assertUndef(eval("1; twoFunc();"));
assertEquals(2, eval("1; with ( { a: 0 } ) { 2; }"));
assertUndef(eval('a: while(true) { do { 0 } while(false); switch(1) { case 0: 1; case 1: break a; }; 0 }'));
assertUndef(eval('a: while(true) { do { 0 } while(false); try {} finally { break a }; 0 }'));
assertUndef(eval('a: while(true) { b: while(true) { 0; break b; }; switch(1) { case 1: break a; }; 2 }'));
assertUndef(eval('a: while(true) { b: while(true) { 0; break b; }; while (true) { break a; }; 2 }'));
assertUndef(eval('while (true) { 20; a:{ break a; } with ({}) break; 30; }'));
assertEquals(42, eval('a: while(true) { switch(0) { case 0: 42; case 1: break a; }; 33 }'));
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