From 03358f85069f70b8079abb84002e4930bc83c21f Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Thu, 17 Jan 2019 23:39:19 +0100 Subject: [PATCH] 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. --- src/fns.c | 3 ++- test/src/fns-tests.el | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fns.c b/src/fns.c index 1ac60321c5..345211418c 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2084,7 +2084,7 @@ the second. */) else if (VECTORP (seq)) sort_vector (seq, predicate); else if (!NILP (seq)) - wrong_type_argument (Qsequencep, seq); + wrong_type_argument (Qlist_or_vector_p, seq); return seq; } @@ -5358,6 +5358,7 @@ Used by `featurep' and `require', and altered by `provide'. */); DEFSYM (Qsubfeatures, "subfeatures"); DEFSYM (Qfuncall, "funcall"); DEFSYM (Qplistp, "plistp"); + DEFSYM (Qlist_or_vector_p, "list-or-vector-p"); #ifdef HAVE_LANGINFO_CODESET DEFSYM (Qcodeset, "codeset"); diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index 3d1a8b37b4..d6cc99e8e3 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el @@ -161,7 +161,10 @@ fns-tests--collate-enabled-p '(9 . "ppp") '(8 . "ttt") '(8 . "eee") '(9 . "fff")) (lambda (x y) (< (car x) (car y)))) [(8 . "xxx") (8 . "bbb") (8 . "ttt") (8 . "eee") - (9 . "aaa") (9 . "zzz") (9 . "ppp") (9 . "fff")]))) + (9 . "aaa") (9 . "zzz") (9 . "ppp") (9 . "fff")])) + ;; Bug#34104 + (should (equal (should-error (sort "cba" #'<) :type 'wrong-type-argument) + '(wrong-type-argument list-or-vector-p "cba")))) (ert-deftest fns-tests-collate-sort () (skip-unless (fns-tests--collate-enabled-p)) -- 2.17.2 (Apple Git-113)