From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Adam Porter Newsgroups: gmane.emacs.devel Subject: pcase map binding form expansion failure on Emacs 27 only Date: Tue, 07 Sep 2021 07:08:56 -0500 Message-ID: <87eea0610n.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13182"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 07 14:11:11 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mNZwV-0003FJ-Mh for ged-emacs-devel@m.gmane-mx.org; Tue, 07 Sep 2021 14:11:11 +0200 Original-Received: from localhost ([::1]:57672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNZwU-0003Cp-9X for ged-emacs-devel@m.gmane-mx.org; Tue, 07 Sep 2021 08:11:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNZua-0001XL-DL for emacs-devel@gnu.org; Tue, 07 Sep 2021 08:09:12 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:49342) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNZuY-0008FR-7k for emacs-devel@gnu.org; Tue, 07 Sep 2021 08:09:12 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mNZuW-0000Ew-9i for emacs-devel@gnu.org; Tue, 07 Sep 2021 14:09:08 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:274228 Archived-At: Hi, I've come upon a very strange--to me, anyway--problem: When byte-compiling a file at package installation time or in a batch session, this pcase binding form: (pcase-let* (((map :max-width) plist)) max-width) correctly expands to this, on Emacs 26.3 and 28.0.50: (let* ((x6 (map-elt plist :max-width))) (let ((max-width x6)) max-width)) However, on Emacs 27, it incorrectly expands to: (let* ((x6 (map-elt plist ':max-width))) (progn max-width)) This leads to warnings, errors, complete failure of the installed package, and repeated bug reports. In these reports, sometimes users reinstall the package in question (sometimes after deleting the package and restarting Emacs) and see the problem resolved, and in other cases, nothing works. (And sometimes the package author mistakenly accuses the users of having configuration problems (which, sometimes, they did, but not always).) I confirmed that this happens even though map.el is installed at version 3.1, and even though that version is actually loaded, by using this form in the file: (eval-when-compile (save-excursion (message "MAP VERSION IS: %S" (package-desc-version (car (alist-get 'map package-alist)))) (message "MAP IS AT: %S" (locate-library "map")) (message "EXPANSION TEST: %S" (macroexpand-all '(pcase-let* (((map :max-width) plist)) max-width))))) Which produces output like (using my makem.sh script[0], which I use for linting and testing Emacs packages locally and on CI): LOG (2021-09-07 11:31:03): Compiling file: bufler-workspace.el... MAP VERSION IS: (3 1) MAP IS AT: "/tmp/tmp.cEPHlNUWYk/27.1/elpa/map-3.1/map.elc" EXPANSION TEST: (let* ((x6 (map-elt plist ':max-width))) (progn max-width)) Eager macro-expansion failure: (void-variable max-width) Even though I submitted the (very small) patch to map.el that added support for the (map :KEYWORD) binding form, I finally had to give in and apply a workaround in my package, using this binding form instead: ((map (:face face) (:max-width max-width)) plist) That form correctly expands on Emacs 26.3, 27, and 28.0.50. So at least I won't get any more bug reports about this problem on my package. But I would like to understand what's going on here, if possible. I'm pretty sure that there's no bug in my code: my the package depends on map 3.1, that version gets installed before my package does, that version is loaded before my package is compiled, and my package does (require 'map). I can't find any reason for it to only fail on Emacs 27. And since it's not only happening in my testing, but in the wild, something certainly seems fishy. The bug report on my package may be found at , but it's long, and I've reproduced the relevant parts here, so hopefully it won't be necessary to refer to it. I considered filing this as a bug report, but since Emacs 27 probably won't get any new releases IIUC, and since I don't think it's a bug in map.el, a discussion here seemed more appropriate. Thanks for any help, Adam 0: https://github.com/alphapapa/makem.sh