unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: "Braun Gábor" <braungb88@gmail.com>
Cc: 38206@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#38206: 26.1; cl-prettyexpand incorrectly expands pushing to structures
Date: Sun, 17 Nov 2019 20:19:58 +0100	[thread overview]
Message-ID: <87imniux7l.fsf@gnus.org> (raw)
In-Reply-To: <62949967.3QoF1lfsEv@gabor> ("Braun Gábor"'s message of "Thu, 14 Nov 2019 09:20:19 +0100")

Braun Gábor <braungb88@gmail.com> writes:

> (let* ((v test-slot)
>        (v (or (cl-block test-p
>                 (and (memq (type-of foo) cl-struct-test-tags) t))
>               (signal 'wrong-type-argument (list 'test foo))))
>        (v (aref foo 1)))
>   (\(setf\ cl-block\) (cons 1 (cl-block v v v)) v v v))
>
> The form in the output is obviously an incorrect expansion of
> (push 1 (test-slot foo)).

Yup.  However, if we give a FULL parameter to the function, it gives the
correct results:

(cl-prettyexpand '(push 1 (test-slot foo)) t)
=>
(progn
  (or (and (memq (type-of foo) cl-struct-test-tags) t)
      (signal 'wrong-type-argument (list 'test foo)))
  (let* ((v foo))
    (aset v 1 (cons 1 (aref v 1)))))

The definition is

(defun cl-prettyexpand (form &optional full)
  "Expand macros in FORM and insert the pretty-printed result.
Optional argument FULL non-nil means to expand all macros,
including `cl-block' and `cl-eval-when'."
[...]
    (setq form (macroexpand-all form
                                (and (not full) '((cl-block) (cl-eval-when)))))

The bug was introduced by a rewrite in 2012, I think, which changed the
implementation radically, which made it pass in that list as a totally
bogus ENVIRONMENT to macroexpand-all.

I think the right change here is to just deprecate the FULL parameter
and remove the 

                                (and (not full) '((cl-block) (cl-eval-when)))))

bit.  Stefan?

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





  reply	other threads:[~2019-11-17 19:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-14  8:20 bug#38206: 26.1; cl-prettyexpand incorrectly expands pushing to structures Braun Gábor
2019-11-17 19:19 ` Lars Ingebrigtsen [this message]
2019-11-17 20:13   ` Stefan Monnier
2019-11-17 20:19     ` Lars Ingebrigtsen
2019-11-17 22:02       ` Stefan Monnier
2019-11-18 10:00         ` Lars Ingebrigtsen
2019-11-20 16:26           ` Richard Stallman

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=87imniux7l.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=38206@debbugs.gnu.org \
    --cc=braungb88@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /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).