]> git.eshelyaron.com Git - emacs.git/commit
cl-preloaded.el: Fix the type lattice
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 26 Mar 2024 17:14:15 +0000 (13:14 -0400)
committerEshel Yaron <me@eshelyaron.com>
Wed, 27 Mar 2024 20:38:47 +0000 (21:38 +0100)
commit6a695e14a1bf32d1733a7decb9263da8355ad74e
tree2892b00b2642d4f19d95bc80b8c0e96b305979a4
parenta86b0c47b87b9d209aa3f61df1d650e426f4567b
cl-preloaded.el: Fix the type lattice

We generally want types to form not just a DAG but a lattice.
If objects can be both `keyword` and `symbol-with-pos`, this
means there should be a more precise type describing this intersection.
If we ever find the need for such a refinement, we could add
such a `keyword-with-pos` type, but here I took the simpler
route of treating `keyword` not as a proper built-in type but
as a second-class type like `natnum`.

While fixing this problem, also fix the problem we had where
`functionp` was not quite adequate to characterize objects of type
`function`, by introducing a new predicate `cl-functionp` for that.

* lisp/emacs-lisp/cl-preloaded.el (cl-functionp): New function.
(function): Use it.
(keyword): Don't declare it as a built-in type.
(user-ptrp): Remove redundant declaration.

* lisp/emacs-lisp/cl-generic.el (cl--generic--unreachable-types):
Delete constant.
(cl-generic-generalizers): Remove corresponding test.

* lisp/emacs-lisp/cl-macs.el (cl-deftype-satisfies): Add entry for
`keyword` type.

* lisp/emacs-lisp/comp.el (comp-known-predicates): Fix type for
negative result of `characterp`.  Remove duplicate `numberp` entry.
Fix types for `keywordp` now that `keyword` is not a built-in type any more.

* test/src/data-tests.el (data-tests--cl-type-of): Add a few cases.
Remove workaround for `function`.

(cherry picked from commit 004f2493a542dd0b804a30e97fc612884ca440f4)
etc/NEWS
lisp/emacs-lisp/cl-generic.el
lisp/emacs-lisp/cl-macs.el
lisp/emacs-lisp/cl-preloaded.el
lisp/emacs-lisp/comp.el
test/src/data-tests.el