]> git.eshelyaron.com Git - emacs.git/commitdiff
Make native compiler tollerant to redefined primitives (bug#44221).
authorAndrea Corallo <akrl@sdf.org>
Mon, 26 Oct 2020 16:31:13 +0000 (16:31 +0000)
committerAndrea Corallo <akrl@sdf.org>
Mon, 26 Oct 2020 16:34:20 +0000 (16:34 +0000)
* lisp/emacs-lisp/comp.el (comp-emit-set-call-subr): Rework based
on the fact that the subr can now be redefined.
* test/src/comp-tests.el (primitive-redefine-compile-44221):
New testcase.

lisp/emacs-lisp/comp.el
test/src/comp-tests.el

index 1808e727bb964bf1a8a9fde87a007f1311fc0560..15b8b3ab8da35d97d12aa5e6c37abef7a291aef9 100644 (file)
@@ -1153,9 +1153,7 @@ Return value is the fall through block name."
 SP-DELTA is the stack adjustment."
     (let ((subr (symbol-function subr-name))
           (nargs (1+ (- sp-delta))))
-      (unless (subrp subr)
-        (signal 'native-ice (list "not a subr" subr)))
-      (let* ((arity (subr-arity subr))
+      (let* ((arity (func-arity subr))
              (minarg (car arity))
              (maxarg (cdr arity)))
         (when (eq maxarg 'unevalled)
index ae96e5d38681159465199a5a5ddb1f8a43cdd157..446a61549d9ca4440395bf451ba38fdb00887a7e 100644 (file)
@@ -430,6 +430,15 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html."
   ;; Bug#42664, Bug#43280, Bug#44209.
   (should-not (subr-native-elisp-p (symbol-function #'comp-test-defsubst-f))))
 
+(comp-deftest primitive-redefine-compile-44221 ()
+  "Test the compiler still works while primitives are redefined (bug#44221)."
+  (cl-letf (((symbol-function #'delete-region)
+             (lambda (_ _))))
+    (should (subr-native-elisp-p
+             (native-compile
+              '(lambda ()
+                 (delete-region (point-min) (point-max))))))))
+
 \f
 ;;;;;;;;;;;;;;;;;;;;;
 ;; Tromey's tests. ;;