diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java index cb3adaf4e8cfe44e27deacdac1635572ecd0e66b..5e51f4a7de834dfd42884873d1abd88e21727c1d 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java @@ -95,6 +95,8 @@ public final class FunctionDefinitionNode extends RRootNode { return ex.getResult(); } finally { if (onExitProfile.profile(onExitSlot != null && onExitSlot.hasValue(vf))) { + // Must preserve the visibility state as it may be changed by the on.exit expression + boolean isVisible = RContext.isVisible(); ArrayList<Object> current = getCurrentOnExitList(vf, onExitSlot.executeFrameSlot(vf)); for (Object expr : current) { if (!(expr instanceof RNode)) { @@ -103,6 +105,7 @@ public final class FunctionDefinitionNode extends RRootNode { RNode node = (RNode) expr; onExitExpressionCache.execute(vf, node); } + RContext.setVisible(isVisible); } } }