diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-11 21:42:19 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-11 21:42:19 -0800 |
commit | 926ad2e614f5c4c817e3ed8b560ded9045a7ccba (patch) | |
tree | ca232f583fd4bca8f9b3b9d89bdb8aab09e42416 | |
parent | b5dbbcee80446c28ef8b3c99a5594dd98bdc948a (diff) | |
download | txr-926ad2e614f5c4c817e3ed8b560ded9045a7ccba.tar.gz txr-926ad2e614f5c4c817e3ed8b560ded9045a7ccba.tar.bz2 txr-926ad2e614f5c4c817e3ed8b560ded9045a7ccba.zip |
Bugfix in case{q,ql,qual} macro expansion.
* eval.c (me_case): The key must be quoted unconditionally
whether it's an atom or list. Let's make this subject
to the compatibility flag in case someone's code depends
on it.
* txr.1: Compat notes added.
-rw-r--r-- | eval.c | 23 | ||||
-rw-r--r-- | txr.1 | 18 |
2 files changed, 35 insertions, 6 deletions
@@ -3157,12 +3157,23 @@ static val me_case(val form, val menv) if (keys == t) eval_error(form_orig, lit("~s: symbol t used as key"), casesym, nao); - ptail = list_collect(ptail, - cons(list(if3(atom(keys), eqfuncsym, memfuncsym), - tformsym, - if3(atom(keys), keys, list(quote_s, keys, nao)), - nao), - forms)); + if (opt_compat && opt_compat <= 156) { + ptail = list_collect(ptail, + cons(list(if3(atom(keys), eqfuncsym, memfuncsym), + tformsym, + if3(atom(keys), + keys, + list(quote_s, keys, nao)), + nao), + forms)); + } else { + ptail = list_collect(ptail, + cons(list(if3(atom(keys), eqfuncsym, memfuncsym), + tformsym, + list(quote_s, keys, nao), + nao), + forms)); + } } if (form && atom(form)) @@ -49312,6 +49312,24 @@ of these version values, the described behaviors are provided if is given an argument which is equal or lower. For instance .code "-C 103" selects the behaviors described below for version 105, but not those for 102. +.IP 156 +After version 156, a bug was fixed in the macro expander for +.codn caseq , +.code caseql +and +.codn casequal . +Selecting a compatibility value of 156 or less restores the buggy +behavior. The bug was that single-atom case keys were undergoing +evaluation. For instance +.code "(caseql x (a 0))" +would arrange for the evaluation of +.code a +as a variable, rather than treating it as the symbol +.code a +itself. Beside using the compatibility mechanism, a workaround is to +use a list of keys, exemplified by a rewrite of the foregoing +expression to +.codn "(caseql x ((a) 0))" . .IP 155 After version 155, the .code tok-str |