From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Declaring Lisp function types Date: Thu, 02 May 2024 14:15:28 +0300 Message-ID: <86le4slb1r.fsf@gnu.org> References: <8634sdjgoj.fsf@gnu.org> <86mspaq4ro.fsf@gnu.org> <8634r0oi2h.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15678"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org, stefankangas@gmail.com, adam@alphapapa.net, arthur.miller@live.com To: Andrea Corallo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu May 02 13:16:31 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s2UQO-0003nT-7G for ged-emacs-devel@m.gmane-mx.org; Thu, 02 May 2024 13:16:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2UPq-0004RF-2I; Thu, 02 May 2024 07:15:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2UPa-0004JA-D1 for emacs-devel@gnu.org; Thu, 02 May 2024 07:15:38 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2UPY-0006AN-OZ; Thu, 02 May 2024 07:15:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=CmU+BUcWM0SX2qwsGE0hB5VRokbAN8OLwl3laVIz4lI=; b=lwolgcpfN9kS YDqIEUSqIkwsrkFpyMpD7z0R5Ilw5HOHrRH0y6z7FfM2C0PWGrGQ2w8PfsOiCgy/DzJ1/NsJuLFru XPNhRu8rPsxVDCyBy6sZ6Al3sW3vpyyt2VhCSDsQyZjTOqa+Nqp/dPOm7nG4UrO1Eido/gubnwONQ NlJFB3VdGtgzrCYn8q/zpXXujlNGhj2Z5Kc62V0PQSdRMes1GPPFqwdOT0A4lUhqaKFuE/JHogos3 bJmrVkZJrBOy2Zg4tOiUgyXfg1q5kqdDr6Aoo57+LpbYoh8RSqY6sIyCVrLGmJ9LJmGduHoI5G0uE viXmpr9Ul4gyagyuCFxiCw==; In-Reply-To: (message from Andrea Corallo on Thu, 02 May 2024 06:12:42 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:318566 Archived-At: > From: Andrea Corallo > 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 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.