bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#58531: 29.0.50; Wrong predicate used by map-elt gv getter


From: Stefan Monnier
Subject: bug#58531: 29.0.50; Wrong predicate used by map-elt gv getter
Date: Sat, 15 Oct 2022 11:52:27 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>  (defun map--plist-delete (map key)
>    (let ((tail map) last)
> @@ -346,7 +399,7 @@ map-contains-key
>  If MAP is an alist, TESTFN defaults to `equal'.
>  If MAP is a plist, `plist-member' is used instead."
>    (if (map--plist-p map)
> -      (plist-member map key)
> +      (map--plist-member map key testfn)
>      (let ((v '(nil)))
>        (not (eq v (alist-get key map v nil (or testfn #'equal)))))))

Hmmm looks like we forgot to mark the `testfn` arg obsolete here with
`advertised-calling-convention` like we did for `map-elt`.
Could you fix that oversight in your patch while you're at it?

> -(defun eudc-plist-member (plist prop)
> -  "Return t if PROP has a value specified in PLIST."
> -  (if (not (= 0 (% (length plist) 2)))
> +(defun eudc--plist-member (plist prop &optional predicate)
> +  "Like `plist-member', but signal on invalid PLIST."
> +  ;; Could also use `plistp', but that would change the error.
> +  (or (zerop (% (length plist) 2))
>        (error "Malformed plist"))
> -  (catch 'found
> -    (while plist
> -      (if (eq prop (car plist))
> -       (throw 'found t))
> -      (setq plist (cdr (cdr plist))))
> -    nil))
> +  (plist-member plist prop predicate))

The current error is poor (it doesn't include the offending plist, for
example), so I think changing it (e.g. using the usual
`wrong-type-argument` error) would be for the better.
I do wonder whether it's worth the trouble keeping the error here, tho,
instead of just using `plist-member` directly.


        Stefan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]