GNU bug report logs - #76573
30.1; native compilation fails for record inside function

Previous Next

Package: emacs;

Reported by: Lin Jian <me <at> linj.tech>

Date: Tue, 25 Feb 2025 23:29:02 UTC

Severity: normal

Found in version 30.1

Done: Andrea Corallo <acorallo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #50 received at 76573 <at> debbugs.gnu.org (full text, mbox):

From: Andrea Corallo <acorallo <at> gnu.org>
To: AKIYAMA Kouhei <misohena <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Lin Jian <me <at> linj.tech>,
 76573 <at> debbugs.gnu.org
Subject: Re: bug#76573: 30.1; native compilation fails for record inside
 function
Date: Wed, 30 Apr 2025 04:02:18 -0400
AKIYAMA Kouhei <misohena <at> gmail.com> writes:

> Hello,
>
> I am the author of el-easydraw, mentioned here as misohena.
>
> I'm confused by this issue (errors during native compilation) because
> I simply used the Record type as described in the Emacs Lisp manual. I
> only used the `record' function, but neither the manual nor the
> docstring mentions that the symbol specified as the first TYPE
> argument needs to be pre-defined. The manual does mention avoiding
> type name conflicts, so I added a prefix.
>
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Records.html
>
> However, after seeing Eli's next message, I tried using `make-record'
> instead of the `record' function, and the error being discussed no
> longer occurred.

Hi!

'make-record' works only because the optimizer knows only about 'record'
:)

I'm more and more convinced now that if 'record' and 'make-record' are
documented to the user the code is valid and the compiler should compile
it.

I'm testing this which demotes the error to a warning:

=========
modified   lisp/emacs-lisp/comp-cstr.el
@@ -35,6 +35,7 @@

;;; Code:
+(require 'warnings)
 (require 'cl-lib)
 (require 'cl-extra) ;HACK: For `cl-find-class' when `cl-loaddefs' is missing.

@@ -338,7 +339,11 @@ comp--intersection
(defun comp-supertypes (type)
   "Return the ordered list of supertypes of TYPE."
   (or (assq type (comp-cstr-ctxt-typeof-types comp-ctxt))
-      (error "Type %S missing from typeof-types!" type)))
+      (progn
+        (display-warning
+         'native-compiler
+         (format "Type %S missing from typeof-types!" type))
+        '(t))))

 (defun comp--union-typesets (&rest typesets)
   "Union types present into TYPESETS."

=========

But if really this is, even if seldomly used, valid code maybe we should
not even signal a warning at this point?  Dunno, Eli WDYT?

  Andrea




This bug report was last modified 3 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.