Commit 55105159 authored by Philipp Stephani's avatar Philipp Stephani

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.
parent 3e125517
Pipeline #577 passed with stage
in 48 minutes and 34 seconds
......@@ -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");
......
......@@ -161,7 +161,10 @@
'(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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment