`named-let` macroexpands incorrectly, causing an infinite loop with `and`
There appears to be a bug in the `compat` package's implementation of the `named-let` macro where certain forms do not terminate as expected.
It's expected that the following two expressions should behave identically:
```el
;; This correctly terminates, returning nil.
(named-let recur ((foo '(1 2 3)))
(if foo
(recur (cdr foo))))
;; This results in an infinite loop.
(named-let recur ((foo '(1 2 3)))
(and foo
(recur (cdr foo))))
```
However, the version using `and` results in an infinite loop, while the `if` version terminates correctly.
This issue was originally pointed out by @gengar on Twitter.
The cause seems to be that the logic for `named-let` defined in `compat-28.el` differs from the native `named-let` implementation in Emacs 28. This divergence suggests that other non-terminating patterns may also exist.
5 条评论