From: Stefan Kangas Date: Tue, 1 Apr 2025 19:25:33 +0000 (+0200) Subject: function-put: signal error with non-symbol X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=47ae1a398e4c4b9baf12be2975e08f8bd97b4f5d;p=emacs.git function-put: signal error with non-symbol * 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) --- diff --git a/lisp/subr.el b/lisp/subr.el index ea9b09ca3cd..1631f4ac621 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -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))) diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 25f1b3403ca..024cbe85bba 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -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)