]> git.eshelyaron.com Git - emacs.git/commit
Warn about lambda expressions in comparisons
authorMattias Engdegård <mattiase@acm.org>
Sat, 17 Dec 2022 13:48:34 +0000 (14:48 +0100)
committerMattias Engdegård <mattiase@acm.org>
Sun, 18 Dec 2022 13:55:02 +0000 (14:55 +0100)
commit730a39e8810e91ad3bb70af191229b78c3858983
tree8dcaf45d517860136fb2302dd866d4c2a48d6ac5
parent68fb06f47fd09d36a3d1d35a4d24bf40489bea19
Warn about lambda expressions in comparisons

Lambda expressions are not comparable; warn about calls such as
(eq x (lambda ...)) etc.

* lisp/emacs-lisp/bytecomp.el (bytecomp--dodgy-eq-arg): Rename to...
(bytecomp--dodgy-eq-arg-p): ...this.  Use pcase.  Add lambda checks.
(bytecomp--value-type-description, bytecomp--arg-type-description)
(bytecomp--check-eq-args, bytecomp--check-memq-args): Add function
checks.  Update calls.  Make compiler-macro arguments optional to
avoid crashes in malformed code.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp--with-warning-test): Simplify argument.  Run each
compilation with a fresh (empty) warning cache.  Add ert-info for
easier debugging.
(bytecomp-warn-dodgy-args-eq, bytecomp-warn-dodgy-args-memq):
Add lambda tests.
lisp/emacs-lisp/bytecomp.el
test/lisp/emacs-lisp/bytecomp-tests.el