fix nontail loops within loops
authorAndy Wingo <wingo@pobox.com>
Tue, 1 Sep 2009 16:07:29 +0000 (18:07 +0200)
committerAndy Wingo <wingo@pobox.com>
Tue, 1 Sep 2009 16:07:29 +0000 (18:07 +0200)
commit7f7b85cbf68a8b83e1ad7bc78379cf2764fc9a1b
treea0c6c9b9730305399a4b35a8d475cdef6bed3f69
parent3f12aedb50122209cf773174d215dc64309b9fe4
fix nontail loops within loops

* module/language/tree-il/compile-glil.scm (flatten): Fix compilation of
  loops within loops in non-tail positions. Will add a test case soon,
  but one way to reproduce it was with the following function:

(define (test)
  (let lp ()
    (pk 'zero)
    (let ((fk (lambda ()
                (let ((fk2 (lambda () (pk 'two))))
                  (let ((fk3 (lambda () (if #t (pk 'three) (fk2)))))
                    (if #t
                        (fk3)
                        (fk2)))))))
      (pk 'one)
      (fk))
    (lp)))

One would expect to see a sequence of "zero one three", but in fact zero
only showed once.

This should fix simplex as well.
module/language/tree-il/compile-glil.scm