* test/src/comp-tests.el (comp-test-73270-1): Define new test.
* test/src/comp-resources/comp-test-funcs.el (comp-test-73270-base)
(comp-test-73270-child1, comp-test-73270-child2)
(comp-test-73270-child3, comp-test-73270-child4)
(comp-test-73270-1-f): Define.
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p): Fix it for nil cstrs.
(cherry picked from commit
cd739d3644be618008e5c369b4e96201a05a3d1b)
(if-let ((pred (get type 'cl-deftype-satisfies)))
(and (null (range cstr))
(null (neg cstr))
- (and (or (null (typeset cstr))
- (equal (typeset cstr) `(,type)))
- (cl-every pred (valset cstr))))
+ (if (null (typeset cstr))
+ (and (valset cstr)
+ (cl-every pred (valset cstr)))
+ (when (equal (typeset cstr) `(,type))
+ ;; (valset cstr) can be nil as well.
+ (cl-every pred (valset cstr)))))
(error "Unknown predicate for type %s" type)))))
t))
(defun comp-test-67883-1-f ()
'#1=(1 . #1#))
+(cl-defstruct comp-test-73270-base)
+(cl-defstruct
+ (comp-test-73270-child1 (:include comp-test-73270-base)))
+(cl-defstruct
+ (comp-test-73270-child2 (:include comp-test-73270-base)))
+(cl-defstruct
+ (comp-test-73270-child3 (:include comp-test-73270-base)))
+(cl-defstruct
+ (comp-test-73270-child4 (:include comp-test-73270-base)))
+
+(defun comp-test-73270-1-f (x)
+ (cl-typecase x
+ (comp-test-73270-child1 'child1)
+ (comp-test-73270-child2 'child2)
+ (comp-test-73270-child3 'child3)
+ (comp-test-73270-child4 'child4)))
+
\f
;;;;;;;;;;;;;;;;;;;;
;; Tromey's tests ;;
"<https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-11/msg00925.html>"
(should-not (comp-test-67239-1-f)))
+(comp-deftest comp-test-73270-1 ()
+ "<https://lists.gnu.org/archive/html/bug-gnu-emacs/2024-09/msg00794.html>"
+ (should (eq (comp-test-73270-1-f (make-comp-test-73270-child4)) 'child4)))
+
\f
;;;;;;;;;;;;;;;;;;;;;
;; Tromey's tests. ;;