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
commit1f6d6acb5b8ed75776249d3032477050ebb92a9a (patch)
tree47c2d1d28f978e7d660b404036cebe98a919ae53
parentb434af5cb21ac4bf8e78639c15fadde9f66f5068 (diff)
downloadtxr-1f6d6acb5b8ed75776249d3032477050ebb92a9a.tar.gz
txr-1f6d6acb5b8ed75776249d3032477050ebb92a9a.tar.bz2
txr-1f6d6acb5b8ed75776249d3032477050ebb92a9a.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)