From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: npostavs@users.sourceforge.net
Cc: Michael Heerdegen <michael_heerdegen@web.de>,
27016@debbugs.gnu.org,
Rafael D Sorkin <rsorkin@perimeterinstitute.ca>
Subject: bug#27016: possible bug in `defsetf'
Date: Fri, 14 Jul 2017 00:32:34 -0400 [thread overview]
Message-ID: <jwvd193abwh.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwv1spjbv5o.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 13 Jul 2017 23:48:16 -0400")
> I'm not sure yet how best way to solve this.
I believe the patch below does the right thing. It's kind of a bummer
that we have to byte-compile the function call by hand, tho. I tested
it only lightly, so please give it a more thorough testing and then feel
free to push it.
Stefan
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index e5b9b47b1d..e6f90e044b 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -498,6 +498,10 @@ byte-compile-macro-environment
Each element looks like (MACRONAME . DEFINITION). It is
\(MACRONAME . nil) when a macro is redefined as a function.")
+(defvar byte-compile-plist-environment nil
+ "Alist of property lists defined in the file being compiled.
+Each element looks like (SYMBOL . PLIST).")
+
(defvar byte-compile-function-environment nil
"Alist of functions defined in the file being compiled.
This is so we can inline them when necessary.
@@ -1585,6 +1589,7 @@ byte-compile-close-variables
;; macroenvironment.
(copy-alist byte-compile-initial-macro-environment))
(byte-compile--outbuffer nil)
+ (byte-compile-plist-environment nil)
(byte-compile-function-environment nil)
(byte-compile-bound-variables nil)
(byte-compile-lexical-variables nil)
@@ -4695,7 +4700,7 @@ byte-compile-file-form-defalias
(if (null fun)
(message "Macro %s unrecognized, won't work in file" name)
(message "Macro %s partly recognized, trying our luck" name)
- (push (cons name (eval fun))
+ (push (cons name (eval fun t))
byte-compile-macro-environment)))
(byte-compile-keep-pending form))))
@@ -4725,6 +4730,33 @@ byte-compile-make-variable-buffer-local
'byte-hunk-handler 'byte-compile-form-make-variable-buffer-local)
(defun byte-compile-form-make-variable-buffer-local (form)
(byte-compile-keep-pending form 'byte-compile-normal-call))
+
+(put 'function-put 'byte-hunk-handler 'byte-compile-function-put)
+(defun byte-compile-function-put (form)
+ (pcase form
+ ((and `(,op ,fun ,prop ,val)
+ (guard (and (macroexp-const-p fun)
+ (macroexp-const-p prop)
+ (or (macroexp-const-p val)
+ ;; Also accept anonymous functions, since
+ ;; we're at top-level which implies they're
+ ;; also constants.
+ (pcase val (`(function (lambda . ,_)) t))))))
+ (byte-compile-push-constant op)
+ (byte-compile-form fun)
+ (byte-compile-form prop)
+ (let* ((fun (eval fun t))
+ (prop (eval prop t))
+ (val (if (macroexp-const-p val)
+ (eval val t)
+ (byte-compile-lambda (cadr val)))))
+ (push (cons fun `(,prop ,val
+ . ,(assq fun byte-compile-plist-environment)))
+ byte-compile-plist-environment)
+ (byte-compile-push-constant val)
+ (byte-compile-out 'byte-call 3)))
+
+ (_ (byte-compile-keep-pending form))))
\f
;;; tags
next prev parent reply other threads:[~2017-07-14 4:32 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-22 6:39 bug#27016: possible bug in `defsetf' Rafael D Sorkin
2017-05-22 12:11 ` npostavs
2017-05-22 20:25 ` Rafael D Sorkin
2017-05-22 21:18 ` npostavs
2017-05-22 23:10 ` Michael Heerdegen
2017-05-22 23:23 ` npostavs
2017-05-23 0:45 ` Michael Heerdegen
2017-05-23 0:51 ` npostavs
2017-05-23 1:18 ` Michael Heerdegen
2017-05-22 22:03 ` Rafael D Sorkin
2017-05-22 23:15 ` npostavs
2017-05-24 4:52 ` Rafael D Sorkin
2017-05-24 22:51 ` Michael Heerdegen
2017-05-25 1:50 ` npostavs
2017-05-25 4:59 ` Rafael D Sorkin
2017-05-25 5:01 ` Rafael D Sorkin
2017-05-25 10:38 ` npostavs
2017-05-25 20:26 ` Michael Heerdegen
2017-05-25 20:42 ` Noam Postavsky
2017-05-25 21:31 ` Michael Heerdegen
2017-05-25 23:03 ` npostavs
2017-05-25 23:40 ` Michael Heerdegen
2017-05-26 3:50 ` Stefan Monnier
2017-05-26 22:51 ` npostavs
2017-05-28 20:45 ` Stefan Monnier
2017-07-02 20:47 ` npostavs
2017-07-03 11:25 ` Michael Heerdegen
2017-07-09 20:13 ` npostavs
2017-07-10 0:26 ` Michael Heerdegen
2017-07-11 1:45 ` npostavs
2017-07-11 16:21 ` Stefan Monnier
2017-07-12 0:55 ` npostavs
2017-07-12 2:01 ` Stefan Monnier
2017-07-13 4:46 ` npostavs
2017-07-13 14:25 ` Stefan Monnier
2017-07-14 0:39 ` npostavs
2017-07-14 3:48 ` Stefan Monnier
2017-07-14 4:32 ` Stefan Monnier [this message]
2017-07-15 14:51 ` npostavs
2017-07-16 1:03 ` Stefan Monnier
2017-08-08 1:18 ` npostavs
2017-05-26 5:05 ` Rafael D Sorkin
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvd193abwh.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=27016@debbugs.gnu.org \
--cc=michael_heerdegen@web.de \
--cc=npostavs@users.sourceforge.net \
--cc=rsorkin@perimeterinstitute.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.