diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | lib.c | 12 |
2 files changed, 20 insertions, 2 deletions
@@ -1,3 +1,13 @@ +2015-02-12 Kaz Kylheku <kaz@kylheku.com> + + * lib.c (lazy_appendv_func, lazy_appendv): Bugfix: append* + was silently ignoring lists after the first atom, instead of + throwing an error. Also, it was not detecting the case that + the last argument is a list which should just be returned, + and instead trying to find its tail in preparation for the + next call to lazy_appendv_func, the consequences being runaway + iteration over an infinite list. + 2015-02-10 Kaz Kylheku <kaz@kylheku.com> * eval.c (symacro_k, fun_k): New keyword variables. @@ -888,11 +888,15 @@ static val lazy_appendv_func(val env, val lcons) rplaca(lcons, last); - if (atom(nonempty)) { + if (nilp(lists)) { rplacd(lcons, nonempty); return nil; } + if (atom(nonempty)) + uw_throwf(error_s, lit("append*: cannot append to atom ~s"), + nonempty, nao); + rplacd(env, lists); { @@ -914,9 +918,13 @@ val lazy_appendv(val lists) break; } - if (atom(nonempty)) + if (nilp(lists)) return nonempty; + if (atom(nonempty)) + uw_throwf(error_s, lit("append*: cannot append to atom ~s"), + nonempty, nao); + { loc ptail = ltail(mkcloc(nonempty)); set(ptail, make_lazy_cons(func_f1(cons(car(deref(ptail)), lists), |