* bug#34104: 26.1; Inaccurate error report of (sort "cba" #'<)
@ 2019-01-16 14:53 mail
2019-01-17 22:43 ` Philipp Stephani
0 siblings, 1 reply; 4+ messages in thread
From: mail @ 2019-01-16 14:53 UTC (permalink / raw)
To: 34104
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#34104: 26.1; Inaccurate error report of (sort "cba" #'<)
2019-01-16 14:53 bug#34104: 26.1; Inaccurate error report of (sort "cba" #'<) mail
@ 2019-01-17 22:43 ` Philipp Stephani
2019-01-18 8:30 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Philipp Stephani @ 2019-01-17 22:43 UTC (permalink / raw)
To: mail; +Cc: 34104
[-- 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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#34104: 26.1; Inaccurate error report of (sort "cba" #'<)
2019-01-17 22:43 ` Philipp Stephani
@ 2019-01-18 8:30 ` Eli Zaretskii
2019-01-19 23:05 ` Philipp Stephani
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2019-01-18 8:30 UTC (permalink / raw)
To: Philipp Stephani; +Cc: mail, 34104
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Thu, 17 Jan 2019 23:43:16 +0100
> Cc: 34104@debbugs.gnu.org
>
> > 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.
LGTM, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#34104: 26.1; Inaccurate error report of (sort "cba" #'<)
2019-01-18 8:30 ` Eli Zaretskii
@ 2019-01-19 23:05 ` Philipp Stephani
0 siblings, 0 replies; 4+ messages in thread
From: Philipp Stephani @ 2019-01-19 23:05 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: mail, 34104-done
Am Fr., 18. Jan. 2019 um 09:31 Uhr schrieb Eli Zaretskii <eliz@gnu.org>:
>
> > From: Philipp Stephani <p.stephani2@gmail.com>
> > Date: Thu, 17 Jan 2019 23:43:16 +0100
> > Cc: 34104@debbugs.gnu.org
> >
> > > 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.
>
> LGTM, thanks.
Pushed as 551051596f.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-19 23:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16 14:53 bug#34104: 26.1; Inaccurate error report of (sort "cba" #'<) mail
2019-01-17 22:43 ` Philipp Stephani
2019-01-18 8:30 ` Eli Zaretskii
2019-01-19 23:05 ` Philipp Stephani
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).