From 8558ecd65fc1c87345353f6352299df04280e729 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sun, 7 Mar 2021 14:55:15 +0000 Subject: [PATCH] Fix string-replace error data * lisp/subr.el (string-replace): Signal an error with data that is a list, and whose contents are consistent with other uses of wrong-length-argument. * test/lisp/subr-tests.el (string-replace): Test for this. (subr-test-define-prefix-command): Pacify byte-compiler warnings. --- lisp/subr.el | 2 +- test/lisp/subr-tests.el | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index 0b563473999..77bc7a33b38 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4784,7 +4784,7 @@ Unless optional argument INPLACE is non-nil, return a new string." "Replace FROMSTRING with TOSTRING in INSTRING each time it occurs." (declare (pure t) (side-effect-free t)) (when (equal fromstring "") - (signal 'wrong-length-argument fromstring)) + (signal 'wrong-length-argument '(0))) (let ((start 0) (result nil) pos) diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index fc5a1eba6d8..7a116aa1299 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -78,10 +78,14 @@ (ert-deftest subr-test-define-prefix-command () (define-prefix-command 'foo-prefix-map) + (defvar foo-prefix-map) + (declare-function foo-prefix-map "subr-tests") (should (keymapp foo-prefix-map)) (should (fboundp #'foo-prefix-map)) ;; With optional argument. (define-prefix-command 'bar-prefix 'bar-prefix-map) + (defvar bar-prefix-map) + (declare-function bar-prefix "subr-tests") (should (keymapp bar-prefix-map)) (should (fboundp #'bar-prefix)) ;; Returns the symbol. @@ -531,7 +535,8 @@ See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19350." (should (equal (string-replace "a" "aa" "aaa") "aaaaaa")) (should (equal (string-replace "abc" "defg" "abc") "defg")) - (should-error (string-replace "" "x" "abc"))) + (should (equal (should-error (string-replace "" "x" "abc")) + '(wrong-length-argument 0)))) (ert-deftest subr-replace-regexp-in-string () (should (equal (replace-regexp-in-string "a+" "xy" "abaabbabaaba") -- 2.39.2