From: Philipp Stephani <p.stephani2@gmail.com>
To: Glenn Morris <rgm@gnu.org>
Cc: 25166@debbugs.gnu.org
Subject: bug#25166: 26.0.50; It shouldn't be possible to set the function cell of nil and t
Date: Mon, 26 Dec 2016 19:41:00 +0000 [thread overview]
Message-ID: <CAArVCkS5XKGcokwgj11=JTE8PCrDqj_rTBnRH=UUpYbCJSd+fQ@mail.gmail.com> (raw)
In-Reply-To: <CAArVCkS990mMYOQMks5qA9TX_cV2UfoyJ2KXeLxLi+dZZsOsyA@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1205 bytes --]
Philipp Stephani <p.stephani2@gmail.com> schrieb am Mo., 26. Dez. 2016 um
20:29 Uhr:
> Glenn Morris <rgm@gnu.org> schrieb am Mo., 12. Dez. 2016 um 21:25 Uhr:
>
> Glenn Morris wrote:
>
> > Philipp wrote:
> >
> >> You can set the function cell of nil and t using `fset' and friends.
> >> But you can't call the `nil' function using (nil) (it does work with
> >> (t)). I think that attempting to set the function cell of nil and t is
> >> almost always a bug -- probably the programmer wanted to set a real
> >> symbol, but some of the constants got passed. I propose to signal an
> >> error (e.g. `setting-constant') whenever the function cell of nil and t
> >> is modified; maybe the same should happen for keywords.
> >
> > I just did this yesterday...
> > See https://debbugs.gnu.org/25110, ba8e883, and 3fd4433.
>
> And now see also ffb1302. :)
> Anyway, I only did "nil", since as you say "t" can actually be called as
> a function. But you are right that it's probably unintended.
>
>
> Thanks! Interestingly the behavior was already added in 1994 (commit
> c15c5d408d696928862ca2848a359231e373556c), but apparently reverted later.
> I'd suggest to simply reinstate that commit.
>
Here's a patch.
[-- Attachment #1.2: Type: text/html, Size: 2569 bytes --]
[-- Attachment #2: 0001-Prevent-setting-the-function-cell-of-t-Bug-25166.txt --]
[-- Type: text/plain, Size: 1713 bytes --]
From 5e47f4f2af44285fc877906c5c7689f66e80baf6 Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Mon, 26 Dec 2016 20:38:04 +0100
Subject: [PATCH] Prevent setting the function cell of t (Bug#25166)
Restore behavior of commit c15c5d408d696928862ca2848a359231e373556c,
and make 'fset' consistent with 'fmakunbound'.
* src/data.c (Ffset): Also disallow setting the function cell of t.
* test/src/data-tests.el (data-tests-fset-fmakunbound): Add unit test.
---
src/data.c | 2 +-
test/src/data-tests.el | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/data.c b/src/data.c
index 821fc37937..0fe4bdf590 100644
--- a/src/data.c
+++ b/src/data.c
@@ -734,7 +734,7 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
register Lisp_Object function;
CHECK_SYMBOL (symbol);
/* Perhaps not quite the right error signal, but seems good enough. */
- if (NILP (symbol))
+ if (NILP (symbol) || EQ (symbol, Qt))
xsignal1 (Qsetting_constant, symbol);
function = XSYMBOL (symbol)->function;
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index 757522e399..2daba91b8f 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -450,3 +450,10 @@ binding-test-some-local
(remove-variable-watcher 'data-tests-lvar collect-watch-data)
(setq data-tests-lvar 6)
(should (null watch-data)))))
+
+(ert-deftest data-tests-fset-fmakunbound ()
+ "Test that Bug#25166 is fixed."
+ (should-error (fset nil #'car) :type 'setting-constant)
+ (should-error (fset t #'car) :type 'setting-constant)
+ (should-error (fmakunbound nil) :type 'setting-constant)
+ (should-error (fmakunbound t) :type 'setting-constant))
--
2.11.0
next prev parent reply other threads:[~2016-12-26 19:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-11 9:41 bug#25166: 26.0.50; It shouldn't be possible to set the function cell of nil and t Philipp
2016-12-11 18:38 ` Glenn Morris
2016-12-12 20:25 ` Glenn Morris
2016-12-26 19:29 ` Philipp Stephani
2016-12-26 19:41 ` Philipp Stephani [this message]
2016-12-26 19:47 ` Eli Zaretskii
2016-12-27 15:15 ` Stefan Monnier
2016-12-27 22:49 ` Eli Zaretskii
2016-12-27 23:11 ` Stefan Monnier
2017-05-01 14:44 ` Philipp Stephani
2017-05-01 15:12 ` Eli Zaretskii
2017-10-27 17:59 ` Noam Postavsky
2017-10-28 16:16 ` Stefan Monnier
2017-10-28 16:45 ` Noam Postavsky
2017-10-29 18:10 ` Stefan Monnier
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='CAArVCkS5XKGcokwgj11=JTE8PCrDqj_rTBnRH=UUpYbCJSd+fQ@mail.gmail.com' \
--to=p.stephani2@gmail.com \
--cc=25166@debbugs.gnu.org \
--cc=rgm@gnu.org \
/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.