From 5e47f4f2af44285fc877906c5c7689f66e80baf6 Mon Sep 17 00:00:00 2001 From: Philipp Stephani 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