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

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

bug#47552: 27.1; cl-defstruct field names matching read-only variables -


From: Michael Heerdegen
Subject: bug#47552: 27.1; cl-defstruct field names matching read-only variables -> bad code
Date: Fri, 16 Jun 2023 05:48:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
> > I'm pretty sure that's the right solution, *but* I don't think it's
> > obvious how to get there: `cl-defstruct` defines the constructor
> > using `cl-defsubst` and its `&key` arguments, so the `:gcs-gone` keyword
> > argument inevitably maps to a `gcs-done` variable by definition of how
> > `&key` is supposed to work.
>
> I'm having a hard time following the code in cl-defstruct -- even where
> things are actually defined.
>
> But...  Indeed doing this "doesn't work":

It still doesn't work - I think this bug had been closed by accident?
The original recipe still fails.

Here is another incarnation of this bug:

#+begin_src emacs-lisp
  (require 'cl-lib)
  (defun xyz ())

  (cl-defstruct barf "Doc" (buffer-file-name (xyz)))

  (defun barf-foo ()
    (let ((barf (make-barf)))
      barf))
#+end_src

~~>

| Debugger entered--Lisp error: (wrong-type-argument stringp (xyz))
|   (let* ((buffer-file-name (car (cdr (or (plist-member --cl-rest-- 
':buffer-file-name) ...
|   make-barf--cmacro((make-barf))
|   apply(make-barf--cmacro (make-barf) nil)
|   macroexp--compiler-macro(make-barf--cmacro (make-barf))
|   #f(compiled-function (form func) #<bytecode 
-0x1ad7ff3c206126be>)(((make-barf)) make-barf)
|   macroexp--expand-all((make-barf))

Here the problem is that the variable `buffer-file-name' is not allowed
to be bound to something that is not a string.

Michael.





reply via email to

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