diff options
| author | David Ponce | 2025-05-07 12:24:00 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2025-05-07 12:24:00 -0400 |
| commit | f6f35644b7f49732fe38fac3c199ef3a6a22abe7 (patch) | |
| tree | ea8523edeed9d226327c9a067ebe5c93f6ff086a | |
| parent | 2eb90d43e6e3b8325503d56c7778b9245b930d88 (diff) | |
| download | emacs-f6f35644b7f49732fe38fac3c199ef3a6a22abe7.tar.gz emacs-f6f35644b7f49732fe38fac3c199ef3a6a22abe7.zip | |
(cl-types-of): Fix two plain bugs
* lisp/emacs-lisp/cl-extra.el (cl-types-of): Fix error handling.
Don't mutate `found` since it's stored as key in the hash-table.
| -rw-r--r-- | lisp/emacs-lisp/cl-extra.el | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el index bd7bb96dd6a..f232f06718e 100644 --- a/lisp/emacs-lisp/cl-extra.el +++ b/lisp/emacs-lisp/cl-extra.el | |||
| @@ -1035,24 +1035,26 @@ TYPES is an internal argument." | |||
| 1035 | (and | 1035 | (and |
| 1036 | ;; If OBJECT is of type, add type to the matching list. | 1036 | ;; If OBJECT is of type, add type to the matching list. |
| 1037 | (if types | 1037 | (if types |
| 1038 | ;; For method dispatch, we don't need to filter out errors, since | 1038 | ;; For method dispatch, we don't need to filter out errors, |
| 1039 | ;; we can presume that method dispatch is used only on | 1039 | ;; since we can presume that method dispatch is used only on |
| 1040 | ;; sanely-defined types. | 1040 | ;; sanely-defined types. |
| 1041 | (cl-typep object type) | 1041 | (cl-typep object type) |
| 1042 | (condition-case-unless-debug e | 1042 | (condition-case-unless-debug e |
| 1043 | (cl-typep object type) | 1043 | (cl-typep object type) |
| 1044 | (error (setq cl--type-list (delq type cl--type-list)) | 1044 | (error (setq cl--type-list (delq type cl--type-list)) |
| 1045 | (warn "cl-types-of %S: %s" | 1045 | (warn "cl-types-of %S: %s" |
| 1046 | type (error-message-string e))))) | 1046 | type (error-message-string e)) |
| 1047 | nil))) | ||
| 1047 | (push type found))) | 1048 | (push type found))) |
| 1048 | (push (cl-type-of object) found) | 1049 | (push (cl-type-of object) found) |
| 1049 | ;; Return an unique value of the list of types OBJECT belongs to, | 1050 | ;; Return an unique value of the list of types OBJECT belongs to, |
| 1050 | ;; which is also the list of specifiers for OBJECT. | 1051 | ;; which is also the list of specifiers for OBJECT. |
| 1051 | (with-memoization (gethash found cl--type-unique) | 1052 | (with-memoization (gethash found cl--type-unique) |
| 1052 | ;; Compute an ordered list of types from the DAG. | 1053 | ;; Compute an ordered list of types from the DAG. |
| 1053 | (merge-ordered-lists | 1054 | (let (dag) |
| 1054 | (mapcar (lambda (type) (cl--class-allparents (cl--find-class type))) | 1055 | (dolist (type found) |
| 1055 | (nreverse found)))))) | 1056 | (push (cl--class-allparents (cl--find-class type)) dag)) |
| 1057 | (merge-ordered-lists dag))))) | ||
| 1056 | 1058 | ||
| 1057 | (defvar cl--type-dispatch-list nil | 1059 | (defvar cl--type-dispatch-list nil |
| 1058 | "List of types that need to be checked during dispatch.") | 1060 | "List of types that need to be checked during dispatch.") |