summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-12-08 07:01:40 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-12-08 07:01:40 -0800
commita621bb39d04e1f77fc45c24a3ac3fc08291533fa (patch)
treedd50be4ca98b8b279bc7ad1e4066461629c98649 /eval.c
parent078819a0ae62eaa981a271e127ecbcf2ce0a435f (diff)
downloadtxr-a621bb39d04e1f77fc45c24a3ac3fc08291533fa.tar.gz
txr-a621bb39d04e1f77fc45c24a3ac3fc08291533fa.tar.bz2
txr-a621bb39d04e1f77fc45c24a3ac3fc08291533fa.zip
case macros: bug in singleton key optimization.
* eval.c (me_case): Reduce (key) to key only if key is an atom. Otherwise we reduce ((a b c)), which is a single list-valued key to (a b c), which looks like three keys. This was introduced on Oct 25, 2017 in commit b72c9309c8d8f1af320dce616a69412510531b48, making it a regression. * tests/012/case.tl: New file. The last test case fails without this bugfix. The others pass either way.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index 4e640923..066a8f2a 100644
--- a/eval.c
+++ b/eval.c
@@ -4166,7 +4166,7 @@ static val me_case(val form, val menv)
hash_keys = keys = expand_eval(cons(list_s, keys), nil, menv);
}
- if (consp(keys) && !cdr(keys))
+ if (consp(keys) && atom(car(keys)) && !cdr(keys))
keys = car(keys);
if (atom(keys)) {