Fix nativecomp ICE compiling structure related code (bug#63674)

* lisp/emacs-lisp/cl-macs.el (cl-defstruct): Define the predicate to
be effective at compile time as native comp relies on `cl-typep' that
relies o predicates to work.

* test/src/comp-resources/comp-test-funcs.el (cl-lib): Require.
(comp-test-struct): Define struct.
(comp-test-63674-1-f): Add new test.
This commit is contained in:
Andrea Corallo 2023-05-24 17:05:26 +02:00
parent b513036770
commit b2b2be98da
2 changed files with 14 additions and 3 deletions

View file

@ -3093,13 +3093,16 @@ To see the documentation for a defined struct type, use
(cons 'and (cdddr pred-form))
`(,predicate cl-x))))
(when pred-form
(push `(,defsym ,predicate (cl-x)
(push `(eval-and-compile
;; Define the predicate to be effective at compile time
;; as native comp relies on `cl-typep' that relies on
;; predicates to be defined as they are registered in
;; cl-deftype-satisfies.
(,defsym ,predicate (cl-x)
(declare (side-effect-free error-free) (pure t))
,(if (eq (car pred-form) 'and)
(append pred-form '(t))
`(and ,pred-form t)))
forms)
(push `(eval-and-compile
(define-symbol-prop ',name 'cl-deftype-satisfies ',predicate))
forms))
(let ((pos 0) (descp descs))