From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#67116: byte-compile-let: reversing the order of evaluation of the clauses CAN make a difference. Date: Sat, 11 Nov 2023 23:52:38 -0500 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39077"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67116@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 12 05:53:42 2023 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 1r22Te-000A1L-3a for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Nov 2023 05:53:42 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r22TM-00072U-PD; Sat, 11 Nov 2023 23:53:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r22TL-00072G-0N for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2023 23:53:23 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r22TK-0000Wo-Nq for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2023 23:53:22 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r22Ty-000372-3k for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2023 23:54:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Nov 2023 04:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67116 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169976481611927 (code B ref -1); Sun, 12 Nov 2023 04:54:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Nov 2023 04:53:36 +0000 Original-Received: from localhost ([127.0.0.1]:54945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r22TX-00036I-S3 for submit@debbugs.gnu.org; Sat, 11 Nov 2023 23:53:36 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:59722) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r22TT-000361-LY for submit@debbugs.gnu.org; Sat, 11 Nov 2023 23:53:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r22Sj-0006zP-35 for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2023 23:52:45 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r22Sh-0000Uh-9b for bug-gnu-emacs@gnu.org; Sat, 11 Nov 2023 23:52:44 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3C393441802; Sat, 11 Nov 2023 23:52:41 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1699764760; bh=YSCvPb5koVfWujPVwQb6PpbISfnNhCCNTAa/T8Uv7bo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=JGXAIaYlDTVBO1ayWWurjmB7Ie9ovlvBsvEgwxqNIpMK9SF0h3cGAsNcLAPwsy/P1 cRb8HsIIWZFiMpeSRs4qcGHBhZgLeDripcat31VAAOmkPTpA0IFkq5VOsCfF0y4VJq sP8Xo74Ktrstrc/LYDEhuHeKAUV3pZvcNMbmRjQHWBiEYSw/5u08oVzvMcnU/8nklq 5/f0CibDuGdE6zu8hjm3OYKudsVD86QiLpn0qequFJ5qrVIwqKQdFxcHUnePVk6/km SOzzAIAw0T2+rvHGaRuN8H1PMX1xF03sMXzzE057zDz42OqW73zWfjAbGOqyY7n6pg OH/TyJ79HAhKg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 063264417DE; Sat, 11 Nov 2023 23:52:40 -0500 (EST) Original-Received: from pastel (unknown [45.72.227.120]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D2B731202A1; Sat, 11 Nov 2023 23:52:39 -0500 (EST) In-Reply-To: (Alan Mackenzie's message of "Sat, 11 Nov 2023 22:48:43 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:274184 Archived-At: > In lisp/emacs-lisp/bytecomp.el (byte-compile-let), when the following > form (from jit-lock--debug-fontify): > > (let > ((beg pos) > (end (setq pos > (next-single-property-change > pos 'fontified > nil (point-max))))) > (put-text-property beg end 'fontified nil) > (jit-lock-fontify-now beg end)) > > gets byte compiled, the order of evaluating BEG and END gets reversed so > that END gets evaluated first. Sounds like a bug. Do you have some recipe to reproduce it? I looked at the bytecode but it's a bit hard to tell what's going on there, since the var names are lost along the way. > The comment in byte-compile-let: > > ;; Bind the variables. > ;; For `let', do it in reverse order, because it makes no > ;; semantic difference, but it is a lot more efficient since the > ;; values are now in reverse order on the stack. > > , is not true. It can make a semantic difference. So doing the binding > in reverse order is a bug. Note that this is talking about the actual binding operations, which is separate from the computation of the values that are to be given. What this is saying is that (let ((X1 E1) (X2 E2)) ...) can be compiled to varbind X2 varbind X1 since computing E pushes it value on the stack, so after the two "compute" we have the values of E1 and E2 on the stack and we can pop them in reverse order. And indeed it should make no difference if we do the `varbind X1` before or after `varbind X2` as long as they get the right value and as long as we don't compute anything which depends on those vars in-between. Stefan