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.

Full log


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




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

Previous Next


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