GNU bug report logs - #42837
26.3; `cl-incf' returns wrong value for (alist-get 'X ALIST 0) when ALIST is nil

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Wed, 12 Aug 2020 21:59:02 UTC

Severity: normal

Found in version 26.3

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


Message #10 received at 42837-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 42837-done <at> debbugs.gnu.org
Subject: Re: bug#42837: 26.3; `cl-incf' returns wrong value for (alist-get 'X
 ALIST 0) when ALIST is nil
Date: Thu, 13 Aug 2020 08:55:25 -0700
Drew Adams <drew.adams <at> oracle.com> writes:

> `cl-incf' should always return the new value of PLACE, after it is
> incremented.  It doesn't, if PLACE is an `alist-get' that returns the
> default value.
>
> (setq ali ())
>
> (cl-incf (alist-get 'a ali 0))
>
> returns ((a . 1)), but it should return just 1, the incremented value
> associated with key `a'.

I can reproduce this on Emacs 26.3 (under emacs -Q).  But it seems to
have been fixed on emacs-27 and current master, where I get:

(progn
   (require 'cl-lib)
   (setq ali ())
   (cl-incf (alist-get 'a ali 0)))

=> 1

I'm therefore closing this bug report.

Best regards,
Stefan Kangas




This bug report was last modified 4 years and 283 days ago.

Previous Next


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