Subject: bug#73874: 29.4; Inconsistent cl-loop behavior with Common Lisp

From: Stefan Kangas <[email-masked]>
Date: Sat, 2 Nov 2024 23:06:29 -0700

Bohong Huang <[email-masked]> writes:

> Hello, Emacs developers! When I was porting a Common Lisp library to
> Emacs Lisp, I found that the following minimal code example fails the
> assertion in Emacs Lisp:
>
> ```lisp
> (cl-loop for i in '(1 2 3)
>          for j = (1- i)
>          and k = (1+ i)
>          do (cl-assert (= i (1+ j) (1- k))))
> ```
>
> But it works fine in any proper Common Lisp implementation:
>
> ```lisp
> (loop for i in '(1 2 3)
>       for j = (1- i)
>       and k = (1+ i)
>       do (assert (= i (1+ j) (1- k))))
> ```
>
> By observing the macro expansion, it seems that `cl-loop` does not
> correctly handle the `for ... and ...` clauses, which should bind
> multiple variables in the current loop context in parallel, but
> `cl-loop` always uses the values from the first iteration.
>
> Thank you in advance for your time on this issue.

Is this a duplicate of Bug#72753?

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72753