[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 5ee4209f30: cl-typep: Emit warning when using a type not know
From: |
Basil L. Contovounesios |
Subject: |
Re: master 5ee4209f30: cl-typep: Emit warning when using a type not known to be a type |
Date: |
Sat, 11 Jun 2022 15:30:33 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Stefan Monnier [2022-06-06 00:04 -0400] wrote:
> branch: master
> commit 5ee4209f307fdf8cde9775539c9596d29edccd6d
> Author: Stefan Monnier <monnier@iro.umontreal.ca>
> Commit: Stefan Monnier <monnier@iro.umontreal.ca>
>
> cl-typep: Emit warning when using a type not known to be a type
>
> `cl-typep` has used a heuristic that if there's a `<foo>-p` function,
> then <foo> can be used as a type. This made sense in the past where
> most types were not officially declared to be (cl-)types, but nowadays
> this just encourages abuses such as using `cl-typecase` with
> "types" like `fbound`. It's also a problem for EIEIO objects, where
> for historical reasons `<foo>-p` tests if the object is of type
> exactly `<foo>` whereas (cl-typep OBJ <foo>) should instead test
> if OBJ is a *subtype* of `<foo>`.
>
> So we change `cl-typep` to emit a warning whenever this "-p" heuristic
> is used, to discourage abuses, encourage the use of explicit
> `cl-deftype` declarations, and try and detect some misuses of
> `<foo>-p` for EIEIO objects.
[...]
I think this change gave rise to the following 'error: success' message:
0. emacs -Q -l cl-lib
1. (cl-typep (make-process :name "" :command '("true")) 'process)
2. C-j
-| Warning: Unknown type: process
=> t
In practice, I see this when using Magit with Forge[0]; see the attached
backtrace which I obtained by adding a call to backtrace before
macroexp-warn-and-return in cl-typep.
Is the following a sufficient fix?
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index ada4f0344d..24a4cec4e2 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -3423,6 +3423,7 @@ cl--macroexp-fboundp
(null . null)
(overlay . overlayp)
(real . numberp)
+ (process . processp)
(sequence . sequencep)
(subr . subrp)
(string . stringp)
Thanks,
--
Basil
[0]: https://magit.vc/manual/forge/
forge-backtrace.txt
Description: Text document
- Re: master 5ee4209f30: cl-typep: Emit warning when using a type not known to be a type,
Basil L. Contovounesios <=