diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-11-27 07:04:02 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-11-27 07:04:02 -0800 |
commit | 1bc186e038228af2ce304e66876c37a156508be3 (patch) | |
tree | a59e3b252838290bb5c4499995d4d20cc3ea67d5 | |
parent | 54bd7026304227f86e1ddd7c006f7c1e09cd267b (diff) | |
download | txr-1bc186e038228af2ce304e66876c37a156508be3.tar.gz txr-1bc186e038228af2ce304e66876c37a156508be3.tar.bz2 txr-1bc186e038228af2ce304e66876c37a156508be3.zip |
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.
-rw-r--r-- | eval.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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)) |