From 7c9358205c1f4982cc7f5a3be7032869d35bc165 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 2 Apr 2018 08:44:08 -0700 Subject: 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. --- share/txr/stdlib/compiler.tl | 1 + 1 file changed, 1 insertion(+) 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) -- cgit v1.2.3