Skip to content

Commit

Permalink
[Truffle] Fix what happens when you raise an exception in 'else'.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Dec 6, 2014
1 parent 3cbe259 commit e17ec06
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
11 changes: 7 additions & 4 deletions core/src/main/java/org/jruby/truffle/nodes/control/TryNode.java
Expand Up @@ -46,11 +46,10 @@ public Object execute(VirtualFrame frame) {
while (true) {
getContext().getSafepointManager().poll();

Object result;

try {
final Object result = tryPart.execute(frame);
elseProfile.enter();
elsePart.executeVoid(frame);
return result;
result = tryPart.execute(frame);
} catch (ControlFlowException exception) {
controlFlowProfile.enter();
throw exception;
Expand All @@ -63,6 +62,10 @@ public Object execute(VirtualFrame frame) {
continue;
}
}

elseProfile.enter();
elsePart.executeVoid(frame);
return result;
}
}

Expand Down
4 changes: 4 additions & 0 deletions spec/truffle/tags/language/method_tags.txt
Expand Up @@ -68,3 +68,7 @@ fails:"A method assigns local variables from method parameters for definition \n
fails:"A method assigns local variables from method parameters for definition \n def m(**k, &b) [k, b] end"
fails:"A method assigns local variables from method parameters for definition \n def m(a, b=1, *c, (*d, (e)), f: 2, g:, h:, **k, &l)\n [a, b, c, d, e, f, g, h, k, l]\n end"
fails:"A method assigns local variables from method parameters for definition \n def m a, b=1, *c, d, e:, f: 2, g:, **k, &l\n [a, b, c, d, e, f, g, k, l]\n end"
fails:"A method assigns local variables from method parameters for definition \n def m(a, (b, c)) [a, b, c] end"
fails:"A method assigns local variables from method parameters for definition \n def m((a, b), (c, d))\n [a, b, c, d]\n end"
fails:"A method assigns local variables from method parameters for definition \n def m(a=1, (b, c)) [a, b, c] end"
fails:"A method assigns local variables from method parameters for definition \n def m(a=1, (b, c), (d, e)) [a, b, c, d, e] end"
1 change: 0 additions & 1 deletion spec/truffle/tags/language/rescue_tags.txt
@@ -1,3 +1,2 @@
fails:The rescue keyword will not rescue errors raised in an else block in the rescue block above it
fails:The rescue keyword can rescue a splatted list of exceptions
fails:The rescue keyword will only rescue the specified exceptions when doing a splat rescue

0 comments on commit e17ec06

Please sign in to comment.