From 2d833cd6c187e93b8766f7a77b8538d36b8ffbad Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 16 Jan 2025 22:31:08 -0500 Subject: [PATCH] 552 cond expand no match (#554) * Issue #552 - Error if no match cond-expand clause * Issue #552 - Document change to cond-expand --- CHANGELOG.md | 1 + scheme/base.sld | 2 +- tests/base.scm | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4407dcd9..1909d54e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Bug Fixes - Added a fix from Yorick Hardy to define `*ai-v4mapped*` to zero on platforms where `AI_V4MAPPED` is undefined. - Updated `sqrt` to properly handle complex results given non-complex input. EG: `(sqrt -1) ==> 1i`. And updated the parser to properly handle `+i` and `-i`. Thanks to Christopher Hebert for the bug reports! +- Updated `cond-expand` to raise an error if no clauses match, instead of returning `#t`. ## 0.36.0 - February 14, 2024 diff --git a/scheme/base.sld b/scheme/base.sld index 9c147353..93cda120 100644 --- a/scheme/base.sld +++ b/scheme/base.sld @@ -407,7 +407,7 @@ (else (error "cond-expand: bad feature" x))) (memq x (features)))) (let expand ((ls (cdr expr))) - (cond ((null? ls)) ; (error "cond-expand: no expansions" expr) + (cond ((null? ls) (error "cond-expand: no expansions" expr)) ((not (pair? (car ls))) (error "cond-expand: bad clause" (car ls))) ((eq? 'else (caar ls)) ;(identifier->symbol (caar ls))) (if (pair? (cdr ls)) diff --git a/tests/base.scm b/tests/base.scm index c67a23b3..28ff2539 100644 --- a/tests/base.scm +++ b/tests/base.scm @@ -54,6 +54,7 @@ (test "o" (read-line p)) ) ) + (else #f) ) (test-group