diff --git a/lisp/subr.el b/lisp/subr.el index 1f5819e299e..a1d718ca5b7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -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 diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index b6cabb4ec2a..3d4f524d630 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -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))