emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Declaring Lisp function types


From: Eli Zaretskii
Subject: Re: Declaring Lisp function types
Date: Thu, 02 May 2024 14:15:28 +0300

> From: Andrea Corallo <acorallo@gnu.org>
> Cc: monnier@iro.umontreal.ca,  emacs-devel@gnu.org,  stefankangas@gmail.com,
>   adam@alphapapa.net,  arthur.miller@live.com
> Date: Thu, 02 May 2024 06:12:42 -0400
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > The text you added says an incorrect type produces undefined behavior.
> > Is that true for all alternatives of calling the function:
> > interpreted, byte-compiled, and native-compiled, or only with some of
> > these?
> 
> AFAIK only native-compiled ATM.  Do you think we should specify that?

Yes, please.

> > "Undefined behavior" sounds scary, and I wonder whether it is really
> > accurate.  If the practical expressions of this UB are only some
> > specific ones, perhaps we should mention them?  For example, UB
> > generally means your entire system could be brought down, but I very
> > much doubt that this could happen due to incorrect type declaration,
> > could it?
> 
> There are probably very few cases that can cause this (ATM I could think
> only of one) but if one pokes at that is actually not that difficult:
> 
> (defun foo ()
>   (declare (type (function () cons)))
>   3)
> 
> (defun bar ()
>   (car (foo)))
> 
> Compiling this code and calling car crashes my Emacs.

It would be fine for now to say that incorrect type declaration could
crash Emacs if the code is natively-compiled and loaded.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]