From: Andrea Corallo Date: Wed, 24 May 2023 15:05:26 +0000 (+0200) Subject: Fix nativecomp ICE compiling structure related code (bug#63674) X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b2b2be98da5825e6bc130999ffe38f5ed615586a;p=emacs.git 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. --- diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 6590b1baa1e..0b09cd7d225 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -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)) diff --git a/test/src/comp-resources/comp-test-funcs.el b/test/src/comp-resources/comp-test-funcs.el index 73da7182a54..d8c72c1a920 100644 --- a/test/src/comp-resources/comp-test-funcs.el +++ b/test/src/comp-resources/comp-test-funcs.el @@ -23,6 +23,8 @@ ;;; Code: +(require 'cl-lib) + (defvar comp-tests-var1 3) (defun comp-tests-varref-f () @@ -530,6 +532,12 @@ (comp-test-62537-1-f)) t) +(cl-defstruct comp-test-struct) + +(defun comp-test-63674-1-f (x) + (or + (if (comp-test-struct-p pkg) x) + t)) ;;;;;;;;;;;;;;;;;;;;