From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#53938: 27.2; Defining function that modifies cl-struct before defining cl-struct Date: Sat, 12 Feb 2022 09:45:44 -0500 Message-ID: References: <87bkzc60b1.fsf@gnus.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25488"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Ignacio Casso , 53938@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 12 15:46:13 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1nItfA-0006TY-Jf for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Feb 2022 15:46:12 +0100 Original-Received: from localhost ([::1]:43960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nItf9-0002Kz-4C for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Feb 2022 09:46:11 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nItf2-0002Kn-GF for bug-gnu-emacs@gnu.org; Sat, 12 Feb 2022 09:46:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39927) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nItf0-0002iQ-Fp for bug-gnu-emacs@gnu.org; Sat, 12 Feb 2022 09:46:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nItf0-0002aD-9u for bug-gnu-emacs@gnu.org; Sat, 12 Feb 2022 09:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Feb 2022 14:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53938 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 53938-submit@debbugs.gnu.org id=B53938.16446771579914 (code B ref 53938); Sat, 12 Feb 2022 14:46:02 +0000 Original-Received: (at 53938) by debbugs.gnu.org; 12 Feb 2022 14:45:57 +0000 Original-Received: from localhost ([127.0.0.1]:33824 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nItev-0002Zq-3Y for submit@debbugs.gnu.org; Sat, 12 Feb 2022 09:45:57 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:35878) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nItes-0002Zc-Bj for 53938@debbugs.gnu.org; Sat, 12 Feb 2022 09:45:55 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 18B888070D; Sat, 12 Feb 2022 09:45:47 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 96A1C80008; Sat, 12 Feb 2022 09:45:45 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1644677145; bh=aQR/0TrPQZGA9TXfl1FtrDvhMxTV1ZKqosTjNEQQHUc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=UCFA3RPNViageqDRlkq2iLjpmMdxLhrzGwcP0jqQo6xj+p23iqiz7Nf50IotiwwSe NcT4Hvv7T9QBNcISWgCPq0vDHi7hrp/UViSJXmrQx5nPLyGCb7qkUMSyh2dhrmvlmS 0oj+E/aYAagKT9RSHRm8f5AEMCcYZrqPCMD2lZulxhle2zW8ewgM2fzCAuoEidXKdo xImLEJsz+OQX4UjKea6321qDhNe87iI/N+biBc778zAiOmHIqvmyCv5uzKziZHcQeg O6ugzV81mn7jjKIiXp16AFAlCwqx+hFudI4JY6QlQ+E6OPlL2D2ylmGNkRiAeivxbD PojzuElQwESbw== Original-Received: from ceviche (modemcable034.207-20-96.mc.videotron.ca [96.20.207.34]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 75655120210; Sat, 12 Feb 2022 09:45:45 -0500 (EST) In-Reply-To: <87bkzc60b1.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 12 Feb 2022 07:55:46 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:226727 Archived-At: Lars Ingebrigtsen [2022-02-12 07:55:46] wrote: > Ignacio Casso writes: >> If you define a function that uses a cl struct before defining the cl >> struct (e.g., because the struct is defined in a package to be autoloade= d and the >> function in your init file), there is an error when calling the function >> later. >> >> Here is a simple elisp file to reproduce it, starting Emacs with "emacs >> -Q": >> >> (require 'cl-macs) Please require `cl-lib` rather than `cl-macs` here. >> (defun change-name (struct new-name) >> (setf (my-struct-name struct) new-name)) >> >> (cl-defstruct my-struct >> name) >> >> (setq my-struct (make-my-struct)) >> >> (change-name my-struct "My struct") >> >> This produces the following error: >> >> Debugger entered--Lisp error: (void-function \(setf\ my-struct-name\)) >> (\(setf\ my-struct-name\) new-name v) > > If you'd byte-compiled this, then the compiler would say > > In end of data: > cl.el: Warning: the function =E2=80=98(setf my-struct-name)=E2=80=99 is n= ot known to be > defined. > > So I think that Emacs is probably working as designed here. But perhaps > Stefan has some comments; added to the CCs. Yes, it's working as designed (because the accessors are supposed to be inlined). OTOH, it should work like you want it if you pass the :noinline option to `cl-defstruct`. Stefan