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. * lisp/emacs-lisp/eieio.el (defclass): Define as type not only at run-time but also for the current compilation unit. * lisp/emacs-lisp/eieio-core.el (class, eieio-object): Define as types. * lisp/emacs-lisp/cl-preloaded.el (cl-struct-define): Don't abuse the "-p" heuristic. * lisp/emacs-lisp/cl-macs.el (cl-deftype-satisfies): Add entries for frames, windows, markers, and overlays. (cl-typep): Emit a warning when using a predicate that is not known to correspond to a type. * lisp/files.el (file-relative-name): Fix error that can trigger if there's an(other) error between loading `files.el` and loading `minibuffer.el`.
This commit is contained in:
parent
b90d2a6a63
commit
5ee4209f30
5 changed files with 32 additions and 13 deletions
|
@ -5354,7 +5354,14 @@ on a DOS/Windows machine, it returns FILENAME in expanded form."
|
|||
(let ((fremote (file-remote-p filename))
|
||||
(dremote (file-remote-p directory))
|
||||
(fold-case (or (file-name-case-insensitive-p filename)
|
||||
read-file-name-completion-ignore-case)))
|
||||
;; During bootstrap, it can happen that
|
||||
;; `read-file-name-completion-ignore-case' is
|
||||
;; not defined yet.
|
||||
;; FIXME: `read-file-name-completion-ignore-case' is
|
||||
;; a user-config which we shouldn't trust to reflect
|
||||
;; the actual file system's semantics.
|
||||
(and (boundp 'read-file-name-completion-ignore-case)
|
||||
read-file-name-completion-ignore-case))))
|
||||
(if ;; Conditions for separate trees
|
||||
(or
|
||||
;; Test for different filesystems on DOS/Windows
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue