bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#53938: 27.2; Defining function that modifies cl-struct before defini


From: Lars Ingebrigtsen
Subject: bug#53938: 27.2; Defining function that modifies cl-struct before defining cl-struct
Date: Sat, 12 Feb 2022 07:55:46 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Ignacio Casso <ignaciocasso@hotmail.com> 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 autoloaded 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)
>
> (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 ‘(setf my-struct-name)’ is not 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.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

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