summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-02 08:44:08 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-02 08:44:08 -0700
commit7c9358205c1f4982cc7f5a3be7032869d35bc165 (patch)
tree47c2d1d28f978e7d660b404036cebe98a919ae53
parentb1b5cfea76b05ff965ba42cc31e53577030d991e (diff)
downloadtxr-7c9358205c1f4982cc7f5a3be7032869d35bc165.tar.gz
txr-7c9358205c1f4982cc7f5a3be7032869d35bc165.tar.bz2
txr-7c9358205c1f4982cc7f5a3be7032869d35bc165.zip
compiler: bugfix: missing case in cond.
* share/txr/stdlib/compiler.tl (compiler comp-cond): Add handling for the case when the cond clause contains only a test form, and no additional forms. In that case, if the value is true, then cond terminates with that value. We can nicely achieve this by using or. This was uncovered while compiling share/txr/stdlib/awk.tl, which contains such a case in (sys:awk-state loop) that handles opening the input source.
-rw-r--r--share/txr/stdlib/compiler.tl1
1 files changed, 1 insertions, 0 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index fd315944..907055ad 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -313,6 +313,7 @@
(defmeth compiler comp-cond (me oreg env form)
(tree-case form
((op) me.(comp-atom oreg nil))
+ ((op (test) . more) me.(compile oreg env ^(or ,test (cond ,*more))))
((op (test . forms) . more) me.(compile oreg env
^(if ,test
(progn ,*forms)