unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: mail@xuchunyang.me
Cc: 34104@debbugs.gnu.org
Subject: bug#34104: 26.1; Inaccurate error report of (sort "cba" #'<)
Date: Thu, 17 Jan 2019 23:43:16 +0100	[thread overview]
Message-ID: <CAArVCkRuQcSyp_9vSg=Q=FZdhp21AkoNST32az6Va861hnW3-w@mail.gmail.com> (raw)
In-Reply-To: <17949751547650399@iva2-6ec8f0a6115e.qloud-c.yandex.net>

[-- Attachment #1: Type: text/plain, Size: 586 bytes --]

Am Mi., 16. Jan. 2019 um 15:54 Uhr schrieb <mail@xuchunyang.me>:
>
>
> Eval (sort "cba" #'<) gives
>
> Debugger entered--Lisp error: (wrong-type-argument sequencep "cba")
>   sort("cba" <)
>   eval((sort "cba" (function <)) nil)
>   elisp--eval-last-sexp(nil)
>   eval-last-sexp(nil)
>   funcall-interactively(eval-last-sexp nil)
>   call-interactively(eval-last-sexp nil nil)
>   command-execute(eval-last-sexp)
>
> the error is inaccurate since "cba" is indeed a sequence
>
> (sequencep "cba")
> ;; => t
>
> it should report "cba" is not a list or vector instead.
>


Here's a patch.

[-- Attachment #2: 0001-Improve-error-data-when-passing-a-wrong-type-to-sort.txt --]
[-- Type: text/plain, Size: 1924 bytes --]

From 03358f85069f70b8079abb84002e4930bc83c21f Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
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)


  reply	other threads:[~2019-01-17 22:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-16 14:53 bug#34104: 26.1; Inaccurate error report of (sort "cba" #'<) mail
2019-01-17 22:43 ` Philipp Stephani [this message]
2019-01-18  8:30   ` Eli Zaretskii
2019-01-19 23:05     ` Philipp Stephani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAArVCkRuQcSyp_9vSg=Q=FZdhp21AkoNST32az6Va861hnW3-w@mail.gmail.com' \
    --to=p.stephani2@gmail.com \
    --cc=34104@debbugs.gnu.org \
    --cc=mail@xuchunyang.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).