]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix intra compilation unit function type declaration
authorAndrea Corallo <acorallo@gnu.org>
Sun, 5 May 2024 21:16:20 +0000 (23:16 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 6 May 2024 16:56:27 +0000 (18:56 +0200)
* lisp/emacs-lisp/comp.el (comp-func): Add 'slot'.
(comp--intern-func-in-ctxt): Update.
(comp--get-function-cstr): Update.

(cherry picked from commit 77f87d4b489fcb332fc3d8d3d4a8080e7e1818fd)

lisp/emacs-lisp/comp.el

index d7cd6b79c8674b6f07d3852e8a4de020879f51a4..b1e4b77ae4022f85192dfebfc45376e3eec3ec5b 100644 (file)
@@ -194,8 +194,10 @@ Useful to hook into pass checkers.")
   (when (symbolp function)
     (let ((f (symbol-function function)))
       (or (gethash f comp-primitive-func-cstr-h)
-          (when-let ((res (function-get function 'function-type)))
-            (comp-type-spec-to-cstr (car res)))))))
+          (when-let ((type (or (when-let ((f (comp--symbol-func-to-fun function)))
+                                 (comp-func-declared-type f))
+                               (function-get function 'function-type))))
+            (comp-type-spec-to-cstr type))))))
 
 ;; Keep it in sync with the `cl-deftype-satisfies' property set in
 ;; cl-macs.el. We can't use `cl-deftype-satisfies' directly as the
@@ -523,6 +525,8 @@ CFG is mutated by a pass.")
          :documentation "Optimization level (see `native-comp-speed').")
   (pure nil :type boolean
         :documentation "t if pure nil otherwise.")
+  (declared-type nil :type list
+        :documentation "Declared function type.")
   (type nil :type (or null comp-mvar)
         :documentation "Mvar holding the derived return type."))
 
@@ -821,6 +825,7 @@ clashes."
             (comp-func-lap func) lap
             (comp-func-frame-size func) (comp--byte-frame-size byte-func)
             (comp-func-speed func) (comp--spill-speed name)
+            (comp-func-declared-type func) (car (comp--spill-decl-spec name 'function-type))
             (comp-func-pure func) (comp--spill-decl-spec name 'pure))
 
       ;; Store the c-name to have it retrievable from