unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Kisaragi Hiu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 68345@debbugs.gnu.org
Subject: bug#68345: 29.1; cl-defstruct'ed struct errors out in the constructor compiler macro if a slot is called "quote"
Date: Tue, 9 Jan 2024 21:32:06 +0900	[thread overview]
Message-ID: <05766552-b1d9-44b6-99fb-6f13c4601746@kisaragi-hiu.com> (raw)

* The problem

If a struct is defined to have a slot called "quote", the constructor
will fail during the compiler macro phase.

     (require 'cl-lib)
     (cl-defstruct my-test quote)
     (make-my-test :quote "'") ; error: (invalid-function "'")

     (put 'make-my-test 'compiler-macro nil) ; disable the compiler macro
     (make-my-test :quote "'") ; => #s(test "'")

I have tested Emacs 25.3, 26.3, 27.2, 28.2, and 29.1; this error is in
all these versions.

* Why this is a bug

This feels like a bug to me, because it's not clear that this would be
an unsupported use case, and because of the inconsistent behavior
between the constructor being inlined vs. without a compiler macro.

* Potential directions

This could be "fixed" by either digging into cl-defstruct and cl-lib
then fixing it properly, or by simply declaring in the documentation
that this is not supported. I wish for a proper fix, but the
documentation workaround also seems fine to me.

* Additional info

This is what the compiler macro for make-my-test expands into:

     (cl-block make-my-test
       (record
        ("'" my-test)
        "'"))

In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38,
cairo version 1.17.8)
Windowing system distributor 'The X.Org Foundation', version 11.0.12101010
System Description: Arch Linux





             reply	other threads:[~2024-01-09 12:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 12:32 Kisaragi Hiu via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-01-09 14:19 ` bug#68345: 29.1; cl-defstruct'ed struct errors out in the constructor compiler macro if a slot is called "quote" Eli Zaretskii
2024-01-09 14:59 ` Gerd Möllmann
2024-01-09 22:46   ` Kisaragi Hiu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-10  5:33     ` Gerd Möllmann
2024-01-10 12:55     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05766552-b1d9-44b6-99fb-6f13c4601746@kisaragi-hiu.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=68345@debbugs.gnu.org \
    --cc=mail@kisaragi-hiu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).