From cdb8e401bb56152250b48d2b31cdaf18557120fb Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 18 Sep 2025 07:37:20 -0400 Subject: [PATCH] avoid unwrap in interruptible invocations --- crates/ark/src/interface.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/ark/src/interface.rs b/crates/ark/src/interface.rs index ef27a089a..4031b7314 100644 --- a/crates/ark/src/interface.rs +++ b/crates/ark/src/interface.rs @@ -2381,7 +2381,9 @@ fn do_resource_namespaces() -> bool { /// `WriteConsoleExt()` method so that we don't have to rely on these fragile /// and incomplete inferences. fn is_auto_printing() -> bool { - let n_frame = harp::session::r_n_frame().unwrap(); + let Ok(n_frame) = harp::session::r_n_frame() else { + return false; + }; // The call-stack is empty so this must be R auto-printing an unclassed object if n_frame == 0 { @@ -2394,10 +2396,12 @@ fn is_auto_printing() -> bool { // let browser = harp::session::r_env_is_browsed(last_frame.sexp).unwrap(); // Detect the `print()` call generated by auto-print with classed objects. - // In tat case the first frame of the stack is a call to `print()` with the + // In that case the first frame of the stack is a call to `print()` with the // function inlined in CAR. This inlining disambiguates with the user typing // a `print()` call at top-level. (Similar logic for the S4 generic `show()`.) - let call = harp::session::r_sys_call(1).unwrap(); + let Ok(call) = harp::session::r_sys_call(1) else { + return false; + }; // For safety if r_typeof(call.sexp) != libr::LANGSXP {