Lines
100 %
Functions
Branches
//! Diverging IF / HANDLER-CASE arms and runtime COND tests whose dead residue
//! (a value compiled after the `throw`/`br`) must not reach the enclosing
//! `else`/`end`. The frame seals it there when it reads the arm dead; an
//! UNWIND-PROTECT whose body raises is the subset where the frame sees the
//! arm live, so only the client seals (`compile_arm`, the runtime COND chain)
//! keep it valid (plan 0014 slices 4.0c-1b, 4.0c-2, 4.0c-3a).
use super::common::compile_and_validate;
const RAISING: &str = r#"(unwind-protect (error 'boom "m") 1)"#;
fn validates_top_level_and_let_bound(form: &str) {
compile_and_validate(form);
compile_and_validate(&format!("(let ((v {form})) v)"));
}
#[test]
fn an_if_arm_is_sealed_by_compile_arm() {
validates_top_level_and_let_bound(&format!(r#"(if (> (entity-count) 5) "s" {RAISING})"#));
fn an_if_arm_whose_eager_call_argument_raises_is_sealed_by_compile_arm() {
validates_top_level_and_let_bound(&format!(r#"(if (> (entity-count) 5) "s" (+ 1 {RAISING}))"#));
fn a_handler_case_body_is_sealed_by_compile_arm() {
validates_top_level_and_let_bound(&format!(r#"(handler-case {RAISING} (boom (e) "x"))"#));
fn a_handler_case_body_whose_eager_call_argument_raises_is_sealed_by_compile_arm() {
validates_top_level_and_let_bound(&format!(r#"(handler-case (+ 1 {RAISING}) (boom (e) "x"))"#));
fn a_runtime_cond_test_is_sealed_by_the_chain() {
validates_top_level_and_let_bound(&format!(
r#"(cond ((> (entity-count) 5) "s") ({RAISING} "t") (t "u"))"#
));
fn a_runtime_cond_test_whose_eager_call_argument_raises_is_sealed_by_the_chain() {
r#"(cond ((> (entity-count) 5) "s") ((+ 1 {RAISING}) "t"))"#
/// ISS-160, like the COND clause below.
fn an_if_arm_with_a_value_after_its_error_is_sealed_by_the_frame() {
validates_top_level_and_let_bound(
r#"(if (> (entity-count) 5) "s" (progn (error 'boom "m") 1))"#,
);
/// ISS-160: the top-level spelling's diverging arm is cleared by the frame's
/// pre-`end` seal.
fn a_cond_clause_with_a_value_after_its_error_is_sealed_by_the_frame() {
r#"(cond ((> (entity-count) 5) "s") (t (error 'boom "m") 1))"#,
/// ISS-160's then-arm spelling: the chain's `br` to its typed block would
/// consume the residue before any boundary seal, so it is skipped.
fn an_if_then_arm_with_a_value_after_its_error_takes_no_branch() {
r#"(if (> (entity-count) 5) (progn (error 'boom "m") 1) "s")"#,
/// ISS-160's non-tail COND clause, the same `br` as the then arm.
fn a_non_tail_cond_clause_with_a_value_after_its_error_takes_no_branch() {
r#"(cond ((> (entity-count) 5) (error 'boom "m") 1) (t "s"))"#,
fn an_if_arm_adding_to_an_error_is_sealed_by_the_frame() {
validates_top_level_and_let_bound(r#"(if (> (entity-count) 5) "s" (+ 1 (error 'boom "m")))"#);
fn an_if_arm_adding_to_a_return_from_is_sealed_by_the_frame() {
r#"(block b (if (> (entity-count) 5) "s" (+ 1 (return-from b "q"))))"#,
fn a_handler_case_body_adding_to_an_error_is_sealed_by_the_frame() {
validates_top_level_and_let_bound(r#"(handler-case (+ 1 (error 'boom "m")) (boom (e) "x"))"#);
fn a_runtime_cond_test_with_a_value_after_its_error_is_sealed_by_the_frame() {
r#"(cond ((> (entity-count) 5) "s") ((progn (error 'boom "m") 1) "t"))"#,