From 38d30d7ce812bcccc5de475dd272eda9fb87e579 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 27 Nov 2018 07:04:02 -0800 Subject: case macros: bugfixes for evaluated keys. * eval.c: Fix incorrect treatment of cases like (caseql* ((a b) ...)). The check for evaluation must come before we do the keys = car(keys) transformation. Also, hash_keys must be updated to the evaluated keys, otherwise if the hash table optimization is used, the table will contain the original expressions as the keys, not their values. --- eval.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eval.c b/eval.c index e1c75197..9219c8d4 100644 --- a/eval.c +++ b/eval.c @@ -3944,16 +3944,16 @@ static val me_case(val form, val menv) if (keys == t) eval_error(form_orig, lit("~s: symbol t used as key"), casesym, nao); - if (consp(keys) && !cdr(keys)) - keys = car(keys); - if (star) { if (atom(keys)) - keys = eval(keys, nil, form); + hash_keys = cons(keys = eval(keys, nil, form), nil); else - keys = eval(cons(list_s, keys), nil, form); + hash_keys = keys = eval(cons(list_s, keys), nil, form); } + if (consp(keys) && !cdr(keys)) + keys = car(keys); + if (atom(keys)) { sethash(hash, keys, index); if (!compares_with_eq(keys)) -- cgit v1.2.3