Lines
100 %
Functions
Branches
//! Regression: a `catch-each` helper body must not inherit the enclosing
//! function's `unwind-protect` frames. The leak only shows here as the
//! `push_unwind_frame` precondition under `--cfg anodized_panic`; the codegen
//! test `unwind_protect_helper_scope` guards it in every build.
use rpc::{ScriptCtx, Session};
use uuid::Uuid;
async fn rpc_response(form: &str) -> String {
let mut session = Session::new(ScriptCtx::new(Uuid::new_v4())).unwrap();
session.handle_form(&format!("(:id 9 :form {form})")).await
}
fn extract_value(response: &str) -> &str {
response
.split_once(":value ")
.map(|(_, rest)| rest.trim_end_matches(')').trim())
.unwrap_or(response)
#[tokio::test(flavor = "current_thread")]
async fn outer_unwind_protect_does_not_disrupt_catch_each_helper_return_from() {
let form = r#"(block a (block b (block c (block d
(unwind-protect
(fold (lambda (acc cell) (+ acc 1)) 0
(catch-each (list 1 2) x (block q (unwind-protect (return-from q x) 0))))
(+ 0 777777))))))"#;
let resp = rpc_response(form).await;
assert!(!resp.contains(":error"), "{resp}");
assert_eq!(
extract_value(&resp),
"2",
"both list items must complete the catch-each per-item helper: {resp}"
);