aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Stephani2019-01-17 23:39:19 +0100
committerPhilipp Stephani2019-01-20 00:04:19 +0100
commit551051596fe51d6e232315eeda8a0a79eb43bfdf (patch)
treedd2b179cb2dbe29fbea8d26fdd73ca8a29dae154
parent3e1255172334f3c0645d37eb92c05a628fa3d548 (diff)
downloademacs-551051596fe51d6e232315eeda8a0a79eb43bfdf.tar.gz
emacs-551051596fe51d6e232315eeda8a0a79eb43bfdf.zip
Improve error data when passing a wrong type to 'sort' (Bug#34104)
* src/fns.c (Fsort): Use 'list-or-vector-p' for error message. (syms_of_fns): Define 'list-or-vector-p'. * test/src/fns-tests.el (fns-tests-sort): Extend unit test.
-rw-r--r--src/fns.c3
-rw-r--r--test/src/fns-tests.el5
2 files changed, 6 insertions, 2 deletions
diff --git a/src/fns.c b/src/fns.c
index 1ac60321c58..345211418cb 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -2084,7 +2084,7 @@ the second. */)
2084 else if (VECTORP (seq)) 2084 else if (VECTORP (seq))
2085 sort_vector (seq, predicate); 2085 sort_vector (seq, predicate);
2086 else if (!NILP (seq)) 2086 else if (!NILP (seq))
2087 wrong_type_argument (Qsequencep, seq); 2087 wrong_type_argument (Qlist_or_vector_p, seq);
2088 return seq; 2088 return seq;
2089} 2089}
2090 2090
@@ -5358,6 +5358,7 @@ Used by `featurep' and `require', and altered by `provide'. */);
5358 DEFSYM (Qsubfeatures, "subfeatures"); 5358 DEFSYM (Qsubfeatures, "subfeatures");
5359 DEFSYM (Qfuncall, "funcall"); 5359 DEFSYM (Qfuncall, "funcall");
5360 DEFSYM (Qplistp, "plistp"); 5360 DEFSYM (Qplistp, "plistp");
5361 DEFSYM (Qlist_or_vector_p, "list-or-vector-p");
5361 5362
5362#ifdef HAVE_LANGINFO_CODESET 5363#ifdef HAVE_LANGINFO_CODESET
5363 DEFSYM (Qcodeset, "codeset"); 5364 DEFSYM (Qcodeset, "codeset");
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index 3d1a8b37b4e..d6cc99e8e33 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -161,7 +161,10 @@
161 '(9 . "ppp") '(8 . "ttt") '(8 . "eee") '(9 . "fff")) 161 '(9 . "ppp") '(8 . "ttt") '(8 . "eee") '(9 . "fff"))
162 (lambda (x y) (< (car x) (car y)))) 162 (lambda (x y) (< (car x) (car y))))
163 [(8 . "xxx") (8 . "bbb") (8 . "ttt") (8 . "eee") 163 [(8 . "xxx") (8 . "bbb") (8 . "ttt") (8 . "eee")
164 (9 . "aaa") (9 . "zzz") (9 . "ppp") (9 . "fff")]))) 164 (9 . "aaa") (9 . "zzz") (9 . "ppp") (9 . "fff")]))
165 ;; Bug#34104
166 (should (equal (should-error (sort "cba" #'<) :type 'wrong-type-argument)
167 '(wrong-type-argument list-or-vector-p "cba"))))
165 168
166(ert-deftest fns-tests-collate-sort () 169(ert-deftest fns-tests-collate-sort ()
167 (skip-unless (fns-tests--collate-enabled-p)) 170 (skip-unless (fns-tests--collate-enabled-p))