diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-04-03 17:02:11 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-04-03 17:02:11 -0700 |
commit | 6934d519958914508da133a6d5851811220e46fb (patch) | |
tree | 79b69842c66141f924913d7533feb228dcf6f258 /lib.c | |
parent | 2561b623c178a08de9cdcda35a5a5fc8f83bdaf7 (diff) | |
download | txr-6934d519958914508da133a6d5851811220e46fb.tar.gz txr-6934d519958914508da133a6d5851811220e46fb.tar.bz2 txr-6934d519958914508da133a6d5851811220e46fb.zip |
Fix failing test case tests/006/freeform-1.txr.
* lib.c (lazy_str_force, lazy_str_force_upto): Use set macro
when assigning lim. This won't cause a problem unless lim is
in the bignum range, however.
(acons_new, aconsq_new): When overwriting the cdr value of
the existing entry, use set. This is the smoking gun;
these functions are used for manipulating bindings.
(sort): After sorting a list, we must mark it as having
been mutated. If a list contains only mature conses or only
fresh conses, there is no problem. But if it contains a mixture,
then sorting could reverse their relationship, causing mature
conses to backpoint to the fresh ones.
(obj_init): Use set when installing the t symbol into the user package.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -3385,7 +3385,7 @@ val lazy_str_force(val lstr) } if (lim) - *cdr_l(lstr->ls.opts) = lim; + set(*cdr_l(lstr->ls.opts), lim); return lstr->ls.prefix; } @@ -3408,7 +3408,7 @@ val lazy_str_force_upto(val lstr, val index) } if (lim) - *cdr_l(lstr->ls.opts) = lim; + set(*cdr_l(lstr->ls.opts), lim); return lt(index, length_str(lstr->ls.prefix)); } @@ -3602,7 +3602,7 @@ val acons_new(val key, val value, val list) val existing = assoc(key, list); if (existing) { - *cdr_l(existing) = value; + set(*cdr_l(existing), value); return list; } else { return cons(cons(key, value), list); @@ -3631,7 +3631,7 @@ val aconsq_new(val key, val value, val list) val existing = assq(key, list); if (existing) { - *cdr_l(existing) = value; + set(*cdr_l(existing), value); return list; } else { return cons(cons(key, value), list); @@ -3848,8 +3848,14 @@ val sort(val seq, val lessfun, val keyfun) if (!keyfun) keyfun = identity_f; - if (consp(seq)) + if (consp(seq)) { + /* The list could have a mixture of generation 0 and 1 + objects. Sorting the list could reverse some of the + pointers between the generations resulting in a backpointer. + Thus we better inform the collector about this object. */ + mut(seq); return sort_list(seq, lessfun, keyfun); + } sort_vec(seq, lessfun, keyfun); return seq; @@ -4050,7 +4056,7 @@ static void obj_init(void) *gethash_l(user_package->pk.symhash, nil_string, 0) = nil; /* t can't be interned, because gethash_l needs t in order to do its job. */ - t = *gethash_l(user_package->pk.symhash, lit("t"), 0) = make_sym(lit("t")); + t = set(*gethash_l(user_package->pk.symhash, lit("t"), 0), make_sym(lit("t"))); set(t->s.package, user_package); null = intern(lit("null"), user_package); |