]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix string-replace error data
authorBasil L. Contovounesios <contovob@tcd.ie>
Sun, 7 Mar 2021 14:55:15 +0000 (14:55 +0000)
committerBasil L. Contovounesios <contovob@tcd.ie>
Sun, 7 Mar 2021 14:55:15 +0000 (14:55 +0000)
* 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
test/lisp/subr-tests.el

index 0b5634739993ff1e604290d50201446d7ccbe898..77bc7a33b38d444b07a19e368ac7fa237e792e81 100644 (file)
@@ -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)
index fc5a1eba6d82ee7e9f70227adbe3f21395cdd93c..7a116aa1299048c9ceb5cbde78f2d1eb6555048b 100644 (file)
 
 (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")