]> git.eshelyaron.com Git - emacs.git/commitdiff
lisp/emacs-lisp/cl-macs.el (cl--define-derived-type): Fix partial bootstrap
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 11 May 2025 05:30:01 +0000 (01:30 -0400)
committerEshel Yaron <me@eshelyaron.com>
Mon, 12 May 2025 19:54:45 +0000 (21:54 +0200)
(cherry picked from commit dfafe1830f06634ec779fd62f7081d4cc4f6d3e7)

lisp/emacs-lisp/cl-macs.el

index 4147ec25dbf8a83b3daf85b8782807cd2bd2542d..5ba10b8641e995a80f3455f0c7a8df07dea686e9 100644 (file)
@@ -3767,38 +3767,40 @@ If PARENTS is non-nil, ARGLIST must be nil."
 ;; loaded before `cl-preloaded.el' is defined.
 (put 'list 'cl-deftype-satisfies #'listp)
 
-(static-if (not (fboundp 'cl--define-derived-type))
-    nil ;; Can't define them yet!
-  (cl-deftype natnum () (declare (parents integer)) '(satisfies natnump))
-  (cl-deftype character () (declare (parents fixnum natnum))
-               '(and fixnum natnum))
-  (cl-deftype base-char () (declare (parents character))
-              '(satisfies characterp))
-  (cl-deftype extended-char () (declare (parents character))
-              '(and character (not base-char)))
-  (cl-deftype keyword () (declare (parents symbol)) '(satisfies keywordp))
-  (cl-deftype command ()
-    ;; FIXME: Can't use `function' as parent because of arrays as
-    ;; keyboard macros, which are redundant since `kmacro.el'!!
-    ;;(declare (parents function))
-    '(satisfies commandp))
-
-  (eval-when-compile
-    (defmacro cl--defnumtype (type base)
-      `(cl-deftype ,type (&optional min max)
-         (list 'and ',base
-               (if (memq min '(* nil)) t
-                 (if (consp min)
-                     `(satisfies . ,(lambda (val) (> val (car min))))
-                   `(satisfies . ,(lambda (val) (>= val min)))))
-               (if (memq max '(* nil)) t
-                 (if (consp max)
-                     `(satisfies . ,(lambda (val) (< val (car max))))
-                   `(satisfies . ,(lambda (val) (<= val max)))))))))
-  ;;(cl--defnumtype integer ??)
-  ;;(cl--defnumtype float ??)
-  ;;(cl--defnumtype number ??)
-  (cl--defnumtype real number))
+;; Thanks to `eval-and-compile', `cl--define-derived-type' is needed
+;; both at compile-time and at runtime, so we need to double-check.
+(static-if (not (fboundp 'cl--define-derived-type)) nil
+  (unless (fboundp 'cl--define-derived-type)
+    (cl-deftype natnum () (declare (parents integer)) '(satisfies natnump))
+    (cl-deftype character () (declare (parents fixnum natnum))
+                '(and fixnum natnum))
+    (cl-deftype base-char () (declare (parents character))
+                '(satisfies characterp))
+    (cl-deftype extended-char () (declare (parents character))
+                '(and character (not base-char)))
+    (cl-deftype keyword () (declare (parents symbol)) '(satisfies keywordp))
+    (cl-deftype command ()
+      ;; FIXME: Can't use `function' as parent because of arrays as
+      ;; keyboard macros, which are redundant since `kmacro.el'!!
+      ;;(declare (parents function))
+      '(satisfies commandp))
+
+    (eval-when-compile
+      (defmacro cl--defnumtype (type base)
+        `(cl-deftype ,type (&optional min max)
+           (list 'and ',base
+                 (if (memq min '(* nil)) t
+                   (if (consp min)
+                       `(satisfies . ,(lambda (val) (> val (car min))))
+                     `(satisfies . ,(lambda (val) (>= val min)))))
+                 (if (memq max '(* nil)) t
+                   (if (consp max)
+                       `(satisfies . ,(lambda (val) (< val (car max))))
+                     `(satisfies . ,(lambda (val) (<= val max)))))))))
+    ;;(cl--defnumtype integer ??)
+    ;;(cl--defnumtype float ??)
+    ;;(cl--defnumtype number ??)
+    (cl--defnumtype real number)))
 
 ;; Additional functions that we can now define because we've defined
 ;; `cl-defsubst' and `cl-typep'.