aboutsummaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-07-17 15:40:06 +0200
committerLudovic Courtès <ludo@gnu.org>2014-07-17 15:40:06 +0200
commit2cf0ea0dbbd5a43a62dadb81948ee29898585dd7 (patch)
tree742b2ea6f4f270f93dd1f0b2acda4ba14a5f806d /guix
parent8aaaae38a37f806a62284c6bce116586d8b66b87 (diff)
downloadgnu-guix-2cf0ea0dbbd5a43a62dadb81948ee29898585dd7.tar
gnu-guix-2cf0ea0dbbd5a43a62dadb81948ee29898585dd7.tar.gz
gexp: Gracefully handle printing of gexps with spliced references.
* guix/gexp.scm (write-gexp): Wrap 'write' call in 'false-if-exception'. * tests/gexp.scm ("printer", "printer vs. ungexp-splicing"): New tests.
Diffstat (limited to 'guix')
-rw-r--r--guix/gexp.scm7
1 files changed, 6 insertions, 1 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 260118affa..c9f6cbe99a 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -60,7 +60,12 @@
(define (write-gexp gexp port)
"Write GEXP on PORT."
(display "#<gexp " port)
- (write (apply (gexp-proc gexp) (gexp-references gexp)) port)
+
+ ;; Try to write the underlying sexp. Now, this trick doesn't work when
+ ;; doing things like (ungexp-splicing (gexp ())) because GEXP's procedure
+ ;; tries to use 'append' on that, which fails with wrong-type-arg.
+ (false-if-exception
+ (write (apply (gexp-proc gexp) (gexp-references gexp)) port))
(format port " ~a>"
(number->string (object-address gexp) 16)))