Comment 1 for bug 309095

Revision history for this message
Roman Marynchak (roman-marynchak) wrote :

This issue has two independent parts. The first one is connected with the wrong order of 'initially' clauses and variables initialization. At the first sight it is easily fixable with the attached patch, which resolves the problems in the very similar case:

 (loop :for x = 0 :then (1+ x)
          :for y = (1+ x) :then (ash y 1)
          :for z :across #(1 3 9 27 81 243)
          :for w = (+ x y z)
          :initially (assert (zerop x))
          :until (>= w 100) :collect w)

This patch works fine when applied to the already running system (using chill.lisp), and loop tests pass, including the example from this post. However, it breaks the build on the late (post-cross-compiler) stage. As for now I have no idea why it happens, so I leave this patch here with the hope that more experienced developers could continue this work, or at least give me some advices.

The second part of the issue is connected with the fact that for-as-across lives completely in the loop main body, without any relation to the loop prologue. Extracting the initialization value from it is a non-trivial task, which should be considered only after the first part of the issue - the wrong order of initial and initialization clauses - is fixed.