GNU bug report logs -
#79711
map.el should not use hash-table-contains-p
Previous Next
To reply to this bug, email your comments to 79711 AT debbugs.gnu.org.
There is no need to reopen the bug first.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79711; Package
emacs.
(Tue, 28 Oct 2025 18:50:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Simen Endsjø <contact <at> simendsjo.me>:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org.
(Tue, 28 Oct 2025 18:50:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
[Commit f60fc1287d499e8c93857b1b96e8bd2467b22c8d] started using
`hash-table-contains-p' several places, including `map.el'.
The commit message says "in files where we can rely on features in Emacs
31" excludes `map.el':
,----
| This replaces open coded versions of the common idiom
| (not (eq (gethash key table 'missing) 'missing))
| with
| (hash-table-contains-p key table)
| in files where we can rely on features in Emacs 31.
`----
`map.el' has [the following notice:]
,----
| ;; Package-Requires: ((emacs "26"))
|
| ;; This is a GNU ELPA :core package. Avoid functionality that is not
| ;; compatible with the version of Emacs recorded above.
`----
The package manager [Straight started using this new version], which in
turn starts (silently) requiring Emacs 31.
[Commit f60fc1287d499e8c93857b1b96e8bd2467b22c8d]
<https://cgit.git.savannah.gnu.org/cgit/emacs.git/commit/lisp/emacs-lisp/map.el?id=f60fc1287d499e8c93857b1b96e8bd2467b22c8d>
[the following notice:]
<https://cgit.git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-lisp/map.el?id=f60fc1287d499e8c93857b1b96e8bd2467b22c8d#n9>
[Straight started using this new version]
<https://github.com/emacs-straight/map/commit/8dc8c119d92ad61f352134e3078e32b2c6cb0719>
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79711; Package
emacs.
(Tue, 28 Oct 2025 19:18:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 79711 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Simen Endsjø <contact <at> simendsjo.me> writes:
> [Commit f60fc1287d499e8c93857b1b96e8bd2467b22c8d] started using
> `hash-table-contains-p' several places, including `map.el'.
>
> The commit message says "in files where we can rely on features in Emacs
> 31" excludes `map.el':
>
> ,----
> | This replaces open coded versions of the common idiom
> | (not (eq (gethash key table 'missing) 'missing))
> | with
> | (hash-table-contains-p key table)
> | in files where we can rely on features in Emacs 31.
> `----
>
> `map.el' has [the following notice:]
> ,----
> | ;; Package-Requires: ((emacs "26"))
> |
> | ;; This is a GNU ELPA :core package. Avoid functionality that is not
> | ;; compatible with the version of Emacs recorded above.
> `----
>
> The package manager [Straight started using this new version], which in
> turn starts (silently) requiring Emacs 31.
The unusual thing here is probably that straight is ignoring the fact
that map has not been marked for release (the last bump to the Version
tag was 2022), but I suppose that is intentional on part of the package
manager...
>
> [Commit f60fc1287d499e8c93857b1b96e8bd2467b22c8d]
> <https://cgit.git.savannah.gnu.org/cgit/emacs.git/commit/lisp/emacs-lisp/map.el?id=f60fc1287d499e8c93857b1b96e8bd2467b22c8d>
>
> [the following notice:]
> <https://cgit.git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-lisp/map.el?id=f60fc1287d499e8c93857b1b96e8bd2467b22c8d#n9>
>
> [Straight started using this new version]
> <https://github.com/emacs-straight/map/commit/8dc8c119d92ad61f352134e3078e32b2c6cb0719>
Hi, this should be easy to fix:
[0001-Remove-usage-of-hash-table-contains-p-in-map.el.patch (text/x-diff, attachment)]
[Message part 3 (text/plain, inline)]
Any objections to pushing this to master?
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79711; Package
emacs.
(Tue, 28 Oct 2025 19:25:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 79711 <at> debbugs.gnu.org (full text, mbox):
> Hi, this should be easy to fix:
> [...]
> (cl-defmethod map-contains-key ((map hash-table) key &optional _testfn)
> "Return non-nil if MAP contains KEY, ignoring TESTFN."
> - (hash-table-contains-p key map))
> + (let ((v '(nil)))
> + (not (eq v (gethash key map v)))))
Maybe better to use 'fbound'? Then once the requirement will be updated
to Emacs 31, the old code could be just removed.
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79711; Package
emacs.
(Tue, 28 Oct 2025 19:33:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 79711 <at> debbugs.gnu.org (full text, mbox):
> Cc: 79711 <at> debbugs.gnu.org
> From: Philip Kaludercic <philipk <at> posteo.net>
> Date: Tue, 28 Oct 2025 19:17:25 +0000
>
> Hi, this should be easy to fix:
Thanks, but wouldn't it be better to add a compatibility shim to
compat.el instead?
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79711; Package
emacs.
(Tue, 28 Oct 2025 19:49:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 79711 <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> linkov.net> writes:
>> Hi, this should be easy to fix:
>> [...]
>> (cl-defmethod map-contains-key ((map hash-table) key &optional _testfn)
>> "Return non-nil if MAP contains KEY, ignoring TESTFN."
>> - (hash-table-contains-p key map))
>> + (let ((v '(nil)))
>> + (not (eq v (gethash key map v)))))
>
> Maybe better to use 'fbound'? Then once the requirement will be updated
> to Emacs 31, the old code could be just removed.
I can amend the commit to do that.
Eli Zaretskii <eliz <at> gnu.org> writes:
>> Cc: 79711 <at> debbugs.gnu.org
>> From: Philip Kaludercic <philipk <at> posteo.net>
>> Date: Tue, 28 Oct 2025 19:17:25 +0000
>>
>> Hi, this should be easy to fix:
>
> Thanks, but wouldn't it be better to add a compatibility shim to
> compat.el instead?
Compete already has already implemented the function, but it will not be
released until at least the Emacs 31 prerelease, so we cannot use that
right now.
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79711; Package
emacs.
(Sat, 01 Nov 2025 14:38:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 79711 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Juri Linkov <juri <at> linkov.net> writes:
>> Hi, this should be easy to fix:
>> [...]
>> (cl-defmethod map-contains-key ((map hash-table) key &optional _testfn)
>> "Return non-nil if MAP contains KEY, ignoring TESTFN."
>> - (hash-table-contains-p key map))
>> + (let ((v '(nil)))
>> + (not (eq v (gethash key map v)))))
>
> Maybe better to use 'fbound'? Then once the requirement will be updated
> to Emacs 31, the old code could be just removed.
Any objections against pushing this to master?
[0001-Check-if-hash-table-contains-p-is-available-in-map.e.patch (text/x-diff, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#79711; Package
emacs.
(Sat, 01 Nov 2025 17:42:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 79711 <at> debbugs.gnu.org (full text, mbox):
>>> Hi, this should be easy to fix:
>>> [...]
>>> (cl-defmethod map-contains-key ((map hash-table) key &optional _testfn)
>>> "Return non-nil if MAP contains KEY, ignoring TESTFN."
>>> - (hash-table-contains-p key map))
>>> + (let ((v '(nil)))
>>> + (not (eq v (gethash key map v)))))
>>
>> Maybe better to use 'fbound'? Then once the requirement will be updated
>> to Emacs 31, the old code could be just removed.
>
> Any objections against pushing this to master?
> [...]
> (cl-defmethod map-contains-key ((map hash-table) key &optional _testfn)
> "Return non-nil if MAP contains KEY, ignoring TESTFN."
> - (hash-table-contains-p key map))
> + ;; FIXME: use `hash-table-contains-p' from Compat when available.
> + (if (fboundp 'hash-table-contains-p)
> + (hash-table-contains-p key map)
> + (let ((v '(nil)))
> + (not (eq v (gethash key map v))))))
Thanks, no objections.
Reply sent
to
Philip Kaludercic <philipk <at> posteo.net>:
You have taken responsibility.
(Sun, 02 Nov 2025 10:35:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Simen Endsjø <contact <at> simendsjo.me>:
bug acknowledged by developer.
(Sun, 02 Nov 2025 10:35:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 79711-done <at> debbugs.gnu.org (full text, mbox):
Juri Linkov <juri <at> linkov.net> writes:
>>>> Hi, this should be easy to fix:
>>>> [...]
>>>> (cl-defmethod map-contains-key ((map hash-table) key &optional _testfn)
>>>> "Return non-nil if MAP contains KEY, ignoring TESTFN."
>>>> - (hash-table-contains-p key map))
>>>> + (let ((v '(nil)))
>>>> + (not (eq v (gethash key map v)))))
>>>
>>> Maybe better to use 'fbound'? Then once the requirement will be updated
>>> to Emacs 31, the old code could be just removed.
>>
>> Any objections against pushing this to master?
>> [...]
>> (cl-defmethod map-contains-key ((map hash-table) key &optional _testfn)
>> "Return non-nil if MAP contains KEY, ignoring TESTFN."
>> - (hash-table-contains-p key map))
>> + ;; FIXME: use `hash-table-contains-p' from Compat when available.
>> + (if (fboundp 'hash-table-contains-p)
>> + (hash-table-contains-p key map)
>> + (let ((v '(nil)))
>> + (not (eq v (gethash key map v))))))
>
> Thanks, no objections.
OK, I have pushed the patch to master. Closing the report.
Thanks again to Simen for reporting the problem!
This bug report was last modified 4 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.