Design decisions

84. Negative sqrt traps in cpl run and cpl build --checked (2026-11-21)

  1. sqrt(x) for x < 0.0 traps with sqrt(<x>) of a negative number (exit 3) in cpl-interp and under -DLOCAL (cpl build --checked), while release builds stay raw std::sqrt(x).
    • Reason: Calling sqrt on a tiny negative float (e.g. r*r - d*d = -1e-15 from rounding) previously produced a silent NaN that poisoned downstream comparisons and sorts (flt_sqrt_neg_nan, the last unhandled case in the P0 floating-point bug-replay class). Checking x < 0.0 in cpl-interp and inside #ifdef LOCAL in cpl::fsqrt catches the domain error identically in debug and checked builds with zero release overhead (-0.0 < 0.0 is false, so sqrt(-0.0) still succeeds). Brings floating-point bug-replay to 6/6 (100%) and total P0 bug-replay to 60/63 (95.2%).
    • Test: sqrt_negative_traps_in_interp_and_checked_cpp_not_release, golden_math_assert_and_input_errors, and bench/goal_tests/bug_replay/flt_sqrt_neg_nan.cp.
    • Reverse: Remove the x < 0.0 check in crates/cpl-interp/src/lib.rs, remove the fsqrt piece from crates/cpl-codegen/src/runtime.rs, and emit std::sqrt(...) directly in crates/cpl-codegen/src/expr.rs.