diff --git a/CHANGELOG.md b/CHANGELOG.md index 24d3a44f..616cd4d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Bug Fixes - Add type checking to record type accessor functions. We now raise an error if the passed object is of the wrong record type. +- Fix issues with expanding `cond-expand` expressions in libraries. Previously there would be issues with the expansion if the code needed to be within the context of a `begin`. ## 0.20 - August 14, 2020 diff --git a/scheme/cyclone/libraries.sld b/scheme/cyclone/libraries.sld index 912a469c..beaac610 100644 --- a/scheme/cyclone/libraries.sld +++ b/scheme/cyclone/libraries.sld @@ -239,8 +239,13 @@ (lambda (d acc) (cond ((tagged-list? 'cond-expand d) - (cons (expander d) acc)) - ;(lib:cond-expand-decls (expander d))) + (let* ((expr (expander d)) + (begin? (and (pair? expr) + (not (member (car expr) + '(import export c-linker-options include-c-header)))))) + (if begin? + (cons `(begin ,expr) acc) + (cons expr acc)))) (else (cons d acc)) )) '()