Subject: Re: bug#69249: bug in native-compile?

From: Andrea Corallo <[email-masked]>
Date: Mon, 19 Feb 2024 02:48:58 -0500

Eli Zaretskii <[email-masked]> writes:

>> Cc: [email-masked]
>> From: Robert Boyer <[email-masked]>
>> Date: Sat, 17 Feb 2024 22:26:27 -0600
>> 
>> Here is a report on what seems to me to be a bug in native-compile.
>> 
>> ----------------------------------------------------------------------
>> 
>> ;; Let us suppose that this is the file "compile-bug.el"
>> 
>> ;; Invoking (native-compile "compile-bug.el") should work, I do believe.
>> ;; However it fails and the error message is printed below.
>> 
>> ;; It cannot be emphasized enough how serious this problem seems to me, Bob
>> ;; Boyer, [email-masked].
>> 
>> ;; The reason it is so SERIOUS is that ANY Lisp compiler would need to be
>> ;; delighted to see such a typing expression as
>> 
>> ;;   (declare (fixnum start end) (vector input scratch))
>> 
>> ;; Why? BECAUSE it means that the compiler does not have to lay down code to
>> ;; type check the type of start, end, input, and scratch!!!!
>> 
>> ;; However, (native-compile "compile-bug.el") results in the following error message:
>> 
>> ;; Compiling file /mnt/chromeos/GoogleDrive/MyDrive/Linux/working/compile-bug.el at Fri Feb 16 08:25:19
>> 2024
>> ;; compile-bug.el:2:45: Warning: Unknown defun property ‘fixnum’ in foo
>> ;; compile-bug.el:2:45: Warning: Unknown defun property ‘vector’ in foo
>> 
>> (defun foo (start end input scratch)
>>   (declare (fixnum start end) (vector input scratch))
>>   (list start end input scratch))
>> 
>> ;; foo works fine
>> 
>> ;; Here is an example form for the invocation of foo:
>> 
>> ;; (foo 1 2 (make-vector 3 4) (make-vector 5 6))
>> 
>> ;; That form runs ok if it is running with foo interpreted.
>> 
>> ;; (byte-compile 'foo) runs ok.
>> 
>> ;; One can run the same form after byte-compiling and it runs ok.
>> 
>> ;; However, (native-compile "compile-bug.el") fails with
>> ;; the error report:
>> 
>> ;; Compiling file /mnt/chromeos/GoogleDrive/MyDrive/Linux/working/compile-bug.el at Fri Feb 16 08:35:04
>> 2024
>> ;; compile-bug.el:12:45: Warning: Unknown defun property ‘fixnum’ in foo
>> ;; compile-bug.el:12:45: Warning: Unknown defun property ‘vector’ in foo
>
> Where did you see these declare forms documented?  I don't see them in
> the ELisp Reference manual.  I think you copied them from some other
> Lisp.  In which case Emacs is correct telling you that these declare
> forms are unknown.
>
> Andrea, Stefan: am I right?

Hi Eli,

yes you are correct, we don't support this (so far at least).

  Andrea