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 | 38d30d7ce812bcccc5de475dd272eda9fb87e579 (patch) | |
tree | a59e3b252838290bb5c4499995d4d20cc3ea67d5 | |
parent | 472d9fe5fe1e89eaad0453830ae57ad59846cdb8 (diff) | |
download | txr-38d30d7ce812bcccc5de475dd272eda9fb87e579.tar.gz txr-38d30d7ce812bcccc5de475dd272eda9fb87e579.tar.bz2 txr-38d30d7ce812bcccc5de475dd272eda9fb87e579.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)) |