GNU bug report logs - #55205
28.1.50; completion--replace illegally mutates completion candidates

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Sun, 1 May 2022 08:29:02 UTC

Severity: normal

Found in version 28.1.50

Done: Daniel Mendler <mail <at> daniel-mendler.de>

Bug is archived. No further changes may be made.

Full log


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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Daniel Mendler <mail <at> daniel-mendler.de>, larsi <at> gnus.org,
 55205 <at> debbugs.gnu.org
Subject: Re: bug#55205: 28.1.50; completion--replace illegally mutates
 completion candidates
Date: Mon, 02 May 2022 17:18:47 -0400
Eli Zaretskii [2022-05-02 19:53:08] wrote:
> Why is it justified in this case?  How is this case different from any
> other case?

I don't think it's different from any other.  It's generally considered
a bug when a function uses things like `sort`, `nconc, or `nreverse on
a list it received as argument (unless the docstring explicitly
mentions that the arg may be modified destructively).  When a user
reports this behavior as unexpected the answer is almost always to fix
the funciton so it doesn't have this side-effect any more.

The same usually holds for text properties on strings.
The fact that `completion--replace` is a function used in the completion
machinery was largely irrelevant to the decision of how to fix
the problem.  Its docstring says:

      "Replace the buffer text between BEG and END with NEWTEXT.
    Moves point to the end of the new text."

and nowhere does it warn that NEWTEXT might be modified along the way,
so removing properties on that string was just a plain and simple bug.


        Stefan





This bug report was last modified 231 days ago.

Previous Next


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