1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-26 16:51:46 -07:00

Make member-if compiler-macro hygienic

* lisp/subr.el (member-if): Use uninterned symbol in
compiler-macro (bug#80647).
This commit is contained in:
Basil L. Contovounesios 2026-03-21 13:10:07 +01:00
parent 9adc553ab9
commit fac42338bb
2 changed files with 14 additions and 1 deletions

View file

@ -1226,7 +1226,8 @@ with
(member-if (lambda (x) (foo (bar x))) items)"
(declare (compiler-macro
(lambda (_)
`(drop-while (lambda (x) (not (funcall ,pred x))) ,list))))
(let ((x (make-symbol "x")))
`(drop-while (lambda (,x) (not (funcall ,pred ,x))) ,list)))))
(drop-while (lambda (x) (not (funcall pred x))) list))
;; This is good to have for improved readability in certain uses, but

View file

@ -1715,6 +1715,18 @@ final or penultimate step during initialization."))
(should (equal (funcall (subr--identity #'any) #'minusp ls) '(-1 -2 -3)))
(should (equal (funcall (subr--identity #'any) #'stringp ls) nil))))
(defun subr-tests--any-memql (x xs)
"Like `memql', but exercising the `compiler-macro' of `any'.
The argument names are important."
(any (lambda (y) (eql x y)) xs))
(ert-deftest subr-any-compiler-macro ()
"Test `compiler-macro' of `any'."
(let ((xs (number-sequence 0 4)))
(dotimes (x (1+ (length xs)))
(should (eq (subr-tests--any-memql x xs)
(memql x xs))))))
(ert-deftest total-line-spacing ()
(progn
(let ((line-spacing 10))