Lines
100 %
Functions
Branches
//! Phase 4 (doc/ops/0010-common-lisp-booleans.org) special-form dispatch
//! regressions — NOT BLOCK exit typing, which is its own later slice (see
//! `doc/ops/0010-common-lisp-booleans.org`'s Phase 4 follow-up entry): every
//! special form with a `stack`/`effect` compiler must dispatch through
//! `special::compile_for_effect`, derived from the registry
//! (`is_eval_only_special_form`), not a hand-maintained name list that
//! silently drops wasm (and once missed `CATCH-EACH`, and categorically
//! couldn't cover `ERROR`, which has no dedicated effect handler of its
//! own). `n` stands for `(rpc-protocol-version)`, which is 1.
use super::*;
// --- every special form with a stack/effect compiler reaches real compile
// in effect position, not the eval-only fallback that never throws. ---
#[tokio::test]
async fn error_in_setf_rhs_is_caught() {
let form = "(handler-case (let ((y 0)) (setf y (error 'x \"m\")) y) (x (e) 4))";
assert_values(&[(form, "4")]).await;
}
async fn error_in_let_body_is_caught() {
// Pre-existing root cause: `(error …)` alone in a `LET` body (no SETF
// involved at all) previously fell through to the eval-only fallback.
let form = "(handler-case (let ((y 0)) (error 'x \"m\") y) (x (e) 4))";
async fn error_in_progn_is_caught() {
let form = "(handler-case (progn (error 'x \"m\") 1) (x (e) 4))";
async fn error_in_if_effect_position_is_caught() {
let form = "(handler-case (let ((y 0)) (if (> (rpc-protocol-version) 0) (setf y (error 'x \"m\"))) y) (x (e) 4))";
async fn error_in_dolist_body_is_caught() {
let form =
"(handler-case (let ((y 0)) (dolist (i (list 1)) (setf y (error 'x \"m\"))) y) (x (e) 4))";
async fn error_in_effect_position_is_caught() {
// --- LABELS is not a pure definition form — it compiles and runs its body
// inline (its `SpecialFormSpec` declares a `stack` producer, unlike
// DEFUN/DEFSTRUCT/DEFMACRO/QUOTE which are eval-only), so it must reach
// real compilation in effect position too. ---
async fn labels_body_runs_in_effect_position() {
let form = "(let ((y 0)) (labels ((f (x) (setf y x))) (f 3)) y)";
assert_values(&[(form, "3")]).await;
async fn error_inside_a_labels_body_in_effect_position_is_caught() {
let form = "(handler-case (progn (labels ((f (x) (error 'x \"m\"))) (f 1)) 1) (x (e) 4))";
// --- a `stack`-producing reflective form (EVAL/COMPILE/DESCRIBE/PP/
// APROPOS/DEFTEST/ASSERT-EQUAL/RUN-TESTS/COVERAGE-DUMP) in effect position
// compiles via its OWN stack path (or, for EVAL, re-dispatches its resolved
// code through the SAME effect compiler) and drops the result, instead of
// its value-position `compile` fallback (which would serialize the
// discarded value onto the RPC output stream ahead of the program's real
// result). ---
async fn eval_in_effect_position_does_not_leak_an_extra_output_entry() {
let form = "(progn (eval '(+ 1 2)) 5)";
assert_values(&[(form, "5")]).await;
async fn eval_of_a_defvar_in_effect_position_registers_it() {
// Fable round-4 finding 5: EVAL's effect path re-dispatches its resolved
// code through `compile_for_effect`, which must handle a DEFVAR (a
// definition form, not a stack value) correctly — this used to raise
// "Undefined symbol: *EV*" because the naive fix routed EVAL's resolved
// code through a stack-only path.
let form = "(progn (eval (quote (defvar *ev* 9))) *ev*)";
assert_values(&[(form, "9")]).await;
async fn describe_in_effect_position_does_not_leak_an_extra_output_entry() {
let form = "(progn (describe 'entity-count) 5)";
async fn pp_in_effect_position_does_not_leak_an_extra_output_entry() {
let form = "(progn (pp 5) 5)";
async fn apropos_in_effect_position_does_not_leak_an_extra_output_entry() {
let form = "(progn (apropos \"entity-count\") 5)";
async fn coverage_dump_in_effect_position_does_not_leak_an_extra_output_entry() {
let form = "(progn (coverage-dump) 5)";