]> git.eshelyaron.com Git - emacs.git/commitdiff
function-put: signal error with non-symbol
authorStefan Kangas <stefankangas@gmail.com>
Tue, 1 Apr 2025 19:25:33 +0000 (21:25 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 3 Apr 2025 16:50:19 +0000 (18:50 +0200)
* lisp/subr.el (function-get): Signal an error if given a non-symbol
for consistency with 'get'.
* test/lisp/subr-tests.el (subr-butlast): Test for the above.

(cherry picked from commit a4ec9ca12969018cdf15b8cc713b3ba054326f99)

lisp/subr.el
test/lisp/subr-tests.el

index ea9b09ca3cda727972e8833b1beed772c19bb375..1631f4ac621a6af6505cd6232b5e35501e5d0ec1 100644 (file)
@@ -4229,6 +4229,8 @@ If AUTOLOAD is non-nil and F is autoloaded, try to load it
 in the hope that it will set PROP.  If AUTOLOAD is `macro', do it only
 if it's an autoloaded macro."
   (declare (important-return-value t))
+  (unless (symbolp f)
+    (signal 'wrong-type-argument (list 'symbolp f)))
   (let ((val nil))
     (while (and (symbolp f)
                 (null (setq val (get f prop)))
index 25f1b3403cad857a1ddc979596840482370c9435..024cbe85bba298ebd765ea3a13c9ec2577d28b63 100644 (file)
@@ -1298,7 +1298,11 @@ final or penultimate step during initialization."))
         (should (eq (function-get 'subr-tests--some-fun 'prop) 'value))
         ;; With an alias.
         (should (eq (function-get 'subr-tests--some-alias 'prop) 'value))
-        (function-put 'subr-tests--some-alias 'prop 'value))
+        (function-put 'subr-tests--some-alias 'prop 'value)
+        (should-error (function-get "non-symbol" 'prop)
+                      :type 'wrong-type-argument)
+        (should-error (function-put "non-symbol" 'prop 'val)
+                      :type 'wrong-type-argument))
     (function-put 'subr-tests--some-fun 'prop nil)))
 
 (defun subr-tests--butlast-ref (list &optional n)