GNU bug report logs - #80103
31.0.50; Subtle test-completion issue with duplicates

Previous Next

Package: emacs;

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

Date: Wed, 31 Dec 2025 15:16:02 UTC

Severity: normal

Found in version 31.0.50

To reply to this bug, email your comments to 80103 AT debbugs.gnu.org.

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

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


Report forwarded to monnier <at> IRO.UMontreal.CA, bug-gnu-emacs <at> gnu.org:
bug#80103; Package emacs. (Wed, 31 Dec 2025 15:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Daniel Mendler <mail <at> daniel-mendler.de>:
New bug report received and forwarded. Copy sent to monnier <at> IRO.UMontreal.CA, bug-gnu-emacs <at> gnu.org. (Wed, 31 Dec 2025 15:16:02 GMT) Full text and rfc822 format available.

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

From: Daniel Mendler <mail <at> daniel-mendler.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; Subtle test-completion issue with duplicates
Date: Wed, 31 Dec 2025 16:14:40 +0100
When duplicate candidates occur in an alist, the predicate of
`test-completion' is checked too late. Compare:

(defvar table '(("x" . 1) ("x" . 2)))
(test-completion "x" table (lambda (x) (= (cdr x) 1))) => t
(test-completion "x" table (lambda (x) (= (cdr x) 2))) => nil

In a strict sense this counts as a bug. On the other hand duplicate
candidates in completion tables are a gray zone. I would like to hear
Stefan's opinion on this (cc'ed).

Original discussion at https://github.com/minad/vertico/discussions/646

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.49, cairo version 1.18.4) of 2025-12-27
Windowing system distributor 'The X.Org Foundation', version 11.0.12101016
System Description: Debian GNU/Linux 13 (trixie)

Configured using:
 'configure --prefix=$HOME/.local/share/emacs
 --without-compress-install --with-tree-sitter --with-native-compilation
 --with-dbus --without-selinux --without-threads --disable-gc-mark-trace
 --without-gsettings --without-gpm --with-cairo --with-cairo-xcb
 --with-xinput2 --with-x-toolkit=gtk3 --without-toolkit-scroll-bars
 'CFLAGS=-O3 -mtune=native -march=native''

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBOTF LIBSYSTEMD
LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP
SOUND SQLITE3 TIFF TREE_SITTER WEBP X11 XDBE XIM XINERAMA XINPUT2 XPM
XRANDR GTK3 ZLIB




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#80103; Package emacs. (Wed, 31 Dec 2025 17:40:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Daniel Mendler <mail <at> daniel-mendler.de>
Cc: 80103 <at> debbugs.gnu.org
Subject: Re: bug#80103: 31.0.50; Subtle test-completion issue with duplicates
Date: Wed, 31 Dec 2025 12:39:42 -0500
> When duplicate candidates occur in an alist, the predicate of
> `test-completion' is checked too late. Compare:
>
> (defvar table '(("x" . 1) ("x" . 2)))
> (test-completion "x" table (lambda (x) (= (cdr x) 1))) => t
> (test-completion "x" table (lambda (x) (= (cdr x) 2))) => nil
>
> In a strict sense this counts as a bug. On the other hand duplicate
> candidates in completion tables are a gray zone. I would like to hear
> Stefan's opinion on this (cc'ed).

I'd count it as a bug, yes.

Duplicates are indeed somewhat problematic because of the kinds of UIs
we want to support, but I think here The Right Thing to do is pretty clear.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#80103; Package emacs. (Tue, 06 Jan 2026 15:22:02 GMT) Full text and rfc822 format available.

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

From: Daniel Mendler <mail <at> daniel-mendler.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 80103 <at> debbugs.gnu.org
Subject: Re: bug#80103: 31.0.50; Subtle test-completion issue with duplicates
Date: Tue, 06 Jan 2026 16:21:13 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> When duplicate candidates occur in an alist, the predicate of
>> `test-completion' is checked too late. Compare:
>>
>> (defvar table '(("x" . 1) ("x" . 2)))
>> (test-completion "x" table (lambda (x) (= (cdr x) 1))) => t
>> (test-completion "x" table (lambda (x) (= (cdr x) 2))) => nil
>>
>> In a strict sense this counts as a bug. On the other hand duplicate
>> candidates in completion tables are a gray zone. I would like to hear
>> Stefan's opinion on this (cc'ed).
>
> I'd count it as a bug, yes.
>
> Duplicates are indeed somewhat problematic because of the kinds of UIs
> we want to support, but I think here The Right Thing to do is pretty clear.

Thanks. I consider this a low priority issue, given the lack of proper
support for duplicates, but I can prepare a patch if you think we should
fix this.

Daniel




This bug report was last modified 5 days ago.

Previous Next


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