From b2b2be98da5825e6bc130999ffe38f5ed615586a Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Wed, 24 May 2023 17:05:26 +0200 Subject: [PATCH] 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. --- lisp/emacs-lisp/cl-macs.el | 9 ++++++--- test/src/comp-resources/comp-test-funcs.el | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) 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)) ;;;;;;;;;;;;;;;;;;;; -- 2.39.2