GNU bug report logs - #37400
Patch for bug in cl-reduce: function called with no arguments when list is empty

Previous Next

Package: emacs;

Reported by: Adrià Garriga <adria.garriga <at> gmail.com>

Date: Fri, 13 Sep 2019 14:38:02 UTC

Severity: minor

Tags: fixed

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37400 in the body.
You can then email your comments to 37400 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#37400; Package emacs. (Fri, 13 Sep 2019 14:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Adrià Garriga <adria.garriga <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 13 Sep 2019 14:38:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Adrià Garriga <adria.garriga <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Patch for bug in cl-reduce: function called with no arguments when
 list is empty
Date: Fri, 13 Sep 2019 09:50:39 +0100
[Message part 1 (text/plain, inline)]
Hello Emacs developers,

I found a bug in cl-reduce, which should be reproducible by running the test in the patch. I'm running 26.2 but the bug is also present in master. Please let me know if there are any problems with the patch (including that it is useless :) or if I need to do something else.

Thank you for your hard work maintaining Emacs!

Adrià Garriga-Alonso

[0001-cl-reduce-avoids-calling-the-function-when-list-is-n.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37400; Package emacs. (Fri, 13 Sep 2019 15:19:01 GMT) Full text and rfc822 format available.

Message #8 received at 37400 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Adrià Garriga <adria.garriga <at> gmail.com>
Cc: 37400 <at> debbugs.gnu.org
Subject: Re: bug#37400: Patch for bug in cl-reduce: function called with no
 arguments when list is empty
Date: Fri, 13 Sep 2019 11:18:27 -0400
Adrià Garriga <adria.garriga <at> gmail.com> writes:

> +(ert-deftest cl-seq-reduce ()
> +  (let ((bad-add (lambda (x y) (+ x y))))
> +    (should-not (cl-reduce bad-add nil))

Actually, I think it's a docstring bug.  The Common Lisp Hyperspec says:

    If the subsequence is empty and no initial-value is given, then the
    function is called with zero arguments, and reduce returns whatever
    function does. This is the only case where the function is called
    with other than two arguments.

It looks like Emacs' current implementation is correct, but the
docstring doesn't explain it accurately.

https://www.cs.cmu.edu/Groups/AI/html/hyperspec/HyperSpec/Body/fun_reduce.html




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37400; Package emacs. (Mon, 07 Oct 2019 04:34:02 GMT) Full text and rfc822 format available.

Message #11 received at 37400 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 37400 <at> debbugs.gnu.org,
 Adrià Garriga <adria.garriga <at> gmail.com>
Subject: Re: bug#37400: Patch for bug in cl-reduce: function called with no
 arguments when list is empty
Date: Mon, 07 Oct 2019 06:33:01 +0200
Noam Postavsky <npostavs <at> gmail.com> writes:

> Actually, I think it's a docstring bug.  The Common Lisp Hyperspec says:
>
>     If the subsequence is empty and no initial-value is given, then the
>     function is called with zero arguments, and reduce returns whatever
>     function does. This is the only case where the function is called
>     with other than two arguments.

I've now added a variation of this to the doc string, and I'm closing
this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 07 Oct 2019 04:34:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 37400 <at> debbugs.gnu.org and Adrià Garriga <adria.garriga <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 07 Oct 2019 04:34:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 04 Nov 2019 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 222 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.