From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58531: 29.0.50; Wrong predicate used by map-elt gv getter Date: Sun, 16 Oct 2022 01:41:54 +0300 Message-ID: <87wn906765.fsf@tcd.ie> References: <87r0zaxeox.fsf@tcd.ie> <874jw6xe9h.fsf@tcd.ie> Reply-To: "Basil L. Contovounesios" Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9921"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Thomas Fitzsimmons , 58531@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 16 00:43:15 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ojpsA-0002Pi-JE for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Oct 2022 00:43:14 +0200 Original-Received: from localhost ([::1]:58930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ojps9-0004CK-9K for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 15 Oct 2022 18:43:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojpry-0004C8-Bd for bug-gnu-emacs@gnu.org; Sat, 15 Oct 2022 18:43:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43686) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ojpry-0004OP-3m for bug-gnu-emacs@gnu.org; Sat, 15 Oct 2022 18:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ojprx-0001ex-VD for bug-gnu-emacs@gnu.org; Sat, 15 Oct 2022 18:43:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Oct 2022 22:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58531 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58531-submit@debbugs.gnu.org id=B58531.16658737326309 (code B ref 58531); Sat, 15 Oct 2022 22:43:01 +0000 Original-Received: (at 58531) by debbugs.gnu.org; 15 Oct 2022 22:42:12 +0000 Original-Received: from localhost ([127.0.0.1]:42764 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ojpr9-0001dh-Vc for submit@debbugs.gnu.org; Sat, 15 Oct 2022 18:42:12 -0400 Original-Received: from mail-ej1-f53.google.com ([209.85.218.53]:36793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ojpr6-0001dR-BJ for 58531@debbugs.gnu.org; Sat, 15 Oct 2022 18:42:10 -0400 Original-Received: by mail-ej1-f53.google.com with SMTP id 13so17562420ejn.3 for <58531@debbugs.gnu.org>; Sat, 15 Oct 2022 15:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=XnVQhEG2zyYV901C4uAeuOZ7juiPtMx632whJDixO4A=; b=Ewd0kuKSYhz+cT5no/aQb8rE4OLMB03cG29d4w85oNuheLFpkbi/Cl21w0Q9xicOZN 30YRJshmGsWeCFBFYT2IvcRNu7oEsKuYbo8qVf2rRbbzLBhBUSEH8IuzTy+IKXImCLPC SS+w9h+7CKTBuy8ZuqBHDfOittv1S4qeIpwnLZIuMmQ8xJ+uLCq6JqGZhJ3hBZAdjpQe 5yXgOQCuz5tDQUQax+Tnk9pzlKCz2w1OI8bOmqXdZzN3r6evFm7J2jyekpjfNNIvYmi1 2yLh4l/G0AE796CtpxnsOZ0r5F4kzJbYxvvufPBG6EX0AhSAAKxz3moCzdSgK88GV0lf W2UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=XnVQhEG2zyYV901C4uAeuOZ7juiPtMx632whJDixO4A=; b=H+Is18mrGFV2ISy7BYWJtS9IOfVSFmIx+f9hHDwxBMuFr3j4OmcgfftE2toH8nZeUk BfnExECQu0iorp4vy1pRcxSunIw+Np9THHtC3XJwsuvVOyfXEjrZFS6QFFozutW0qMK2 xXFfJGgSK76GmzvSZJ3zD9orTMq7qnxO98ZeXtExjPU+VS2Qiw7MSFijbT8SSQmmru5/ Ss0nODNfzzzRh+u1Sk0enhImkc66dfOtgyYwmosk+Yd3E7yN64rqPy4yapDzr3TpiJR3 8vDrDPBhStoLMYHu3x8xelmeJCGkeHG2OSajn1QNKdY4pRgsT+sVvAQ3UviOusXnvu8k ucPA== X-Gm-Message-State: ACrzQf2LFd6uHZTERGh+YM09oBCSBaUgHoK3k3NP/by2Xb3mVl6OFKWO Bg/SepTox8ujwULxh0CTW8zDsw== X-Google-Smtp-Source: AMsMyM7o/NOw4aoRm8RIzVkX6hHyzF+o2vdn0in5yADGy+8w7NvB+syKBmopwpFyrHHxhN6U4x1Y0A== X-Received: by 2002:a17:907:2701:b0:78d:cb12:6d94 with SMTP id w1-20020a170907270100b0078dcb126d94mr3546159ejk.344.1665873722436; Sat, 15 Oct 2022 15:42:02 -0700 (PDT) Original-Received: from localhost ([2a02:587:321f:7e8a:d9:365a:ced1:b3d1]) by smtp.gmail.com with ESMTPSA id k10-20020a170906578a00b007306a4ecc9dsm3797102ejq.18.2022.10.15.15.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Oct 2022 15:42:01 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sat, 15 Oct 2022 11:52:27 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:245587 Archived-At: Stefan Monnier [2022-10-15 11:52 -0400] wrote: >> (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? Sure, but generic functions don't play well with advertised-calling-convention: each subsequent cl-defmethod overwrites the preceding symbol-function, so any existing entry in advertised-signature-table is no longer found after that. What would you propose doing? Call set-advertised-calling-convention after the last cl-defmethod in map.el and hope no third-party code defines a new method? It's not ideal, but it's better than what we currently have. Or is there some other trick we can employ that works in Emacs 26+? >> -(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. I was just being conservative, because I don't know where EUDC might get its data from, or how important it is to catch dubious plists red-handed. I'd be happy to simplify the code, but let's see if Thomas (CCed) has any comments. Thomas, the patch touching eudc.el can be found at: https://bugs.gnu.org/58531#8. Thanks, -- Basil