letrec* evaluates incorrect order

Issue #38 resolved
Takashi Kato repo owner created an issue

Following expression is evaluated in incorrect order.

(let ()
  (letrec* ((one1 (begin (display "one-1\n") '11))
            (one2 (begin (display "one-2\n") '12))
            (one3 (begin (display "one-3\n") '13))
            (two1 (begin (display "two-1\n") '11))
            (two2 (begin (display "two-2\n") '12))
            (two3 (begin (display "two-3\n") '13)))
   (list one1 two1)))

Expected; prints all in order and returns '(11 11)

Actual result; prints

one-1
two-1
one-2
one-3
two-2
two-3

and returns '(11 11)

Comments (3)

  1. Takashi Kato reporter
    • changed status to open

    The fix introduced this bug;

      (define foo
        (lambda (form rename compare)
          (letrec* ((bar (lambda (a b) (cons a b)))
            (buzz (lambda (c d) (cons (bar c #f) d))))
        (buzz grr brr))))
    

    Above causes an error but it's totally valid.

  2. Log in to comment