summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/comp.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2024-03-26 13:14:15 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2024-03-26 13:14:15 -0400
commit004f2493a542dd0b804a30e97fc612884ca440f4 (patch)
tree3c20c07a1328e344ff90e3cceb8b96c32cd28a0f /lisp/emacs-lisp/comp.el
parent351d98535dc10f8338b8a418e331cc0af488087b (diff)
downloademacs-004f2493a542dd0b804a30e97fc612884ca440f4.tar.gz
emacs-004f2493a542dd0b804a30e97fc612884ca440f4.tar.bz2
emacs-004f2493a542dd0b804a30e97fc612884ca440f4.zip
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`.
Diffstat (limited to 'lisp/emacs-lisp/comp.el')
-rw-r--r--lisp/emacs-lisp/comp.el6
1 files changed, 3 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index 9976a58f893..2544be85bb2 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -193,13 +193,14 @@ Useful to hook into pass checkers.")
;; cl-macs.el. We can't use `cl-deftype-satisfies' directly as the
;; relation type <-> predicate is not bijective (bug#45576).
(defconst comp-known-predicates
+ ;; FIXME: Auto-generate (most of) it from `cl-deftype-satifies'?
'((arrayp array)
(atom atom)
(bool-vector-p bool-vector)
(booleanp boolean)
(bufferp buffer)
(char-table-p char-table)
- (characterp fixnum)
+ (characterp fixnum t)
(consp cons)
(floatp float)
(framep frame)
@@ -207,14 +208,13 @@ Useful to hook into pass checkers.")
(hash-table-p hash-table)
(integer-or-marker-p integer-or-marker)
(integerp integer)
- (keywordp keyword)
+ (keywordp symbol t)
(listp list)
(markerp marker)
(natnump (integer 0 *))
(null null)
(number-or-marker-p number-or-marker)
(numberp number)
- (numberp number)
(obarrayp obarray)
(overlayp overlay)
(processp process)