diff --git a/reader.c b/reader.c index 0260aaa..0884a02 100644 --- a/reader.c +++ b/reader.c @@ -590,11 +590,15 @@ static void set_placeholder(reader_state_t *state, value_t place, value_t value) static void finalize_placeholders(reader_state_t *state) { - for (bool changed = true; changed; changed = false) + bool changed = true; + + /* We're done when no placeholders link to other placeholders. */ + while (changed) { - /* On each cycle, placeholder cycles/lists should come one link closer to self or actual value. - * Self-links indicate cycles and are replaced with UNDEFINED. - * We're done when no placeholders link to other placeholders. */ + changed = false; + + /* Resolve one level of placeholder-to-placeholder links. + * Self-links indicate cycles and are replaced with UNDEFINED. */ for (value_t item = state->ref_alist.value; !is_nil(item); item = _CDDR(item)) { if (_CADR(item) == item)