From unknown Sun Aug 10 16:50:37 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#24171 <24171@debbugs.gnu.org> To: bug#24171 <24171@debbugs.gnu.org> Subject: Status: 25.1; Bytecode returns nil instead of expected closure Reply-To: bug#24171 <24171@debbugs.gnu.org> Date: Sun, 10 Aug 2025 23:50:37 +0000 retitle 24171 25.1; Bytecode returns nil instead of expected closure reassign 24171 emacs submitter 24171 Michael Heerdegen severity 24171 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 06 19:22:15 2016 Received: (at submit) by debbugs.gnu.org; 6 Aug 2016 23:22:15 +0000 Received: from localhost ([127.0.0.1]:58213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWAv1-0006nw-Gj for submit@debbugs.gnu.org; Sat, 06 Aug 2016 19:22:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38367) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWAuz-0006nk-3w for submit@debbugs.gnu.org; Sat, 06 Aug 2016 19:22:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWAus-00063s-To for submit@debbugs.gnu.org; Sat, 06 Aug 2016 19:22:08 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:49628) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWAus-00063o-Qg for submit@debbugs.gnu.org; Sat, 06 Aug 2016 19:22:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWAuq-00050W-Hp for bug-gnu-emacs@gnu.org; Sat, 06 Aug 2016 19:22:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWAun-00063X-CG for bug-gnu-emacs@gnu.org; Sat, 06 Aug 2016 19:22:04 -0400 Received: from mout.web.de ([217.72.192.78]:57868) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWAun-00063O-2H for bug-gnu-emacs@gnu.org; Sat, 06 Aug 2016 19:22:01 -0400 Received: from drachen.dragon ([88.67.73.210]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0LhNnw-1ashDH182S-00meIE; Sun, 07 Aug 2016 01:16:51 +0200 From: Michael Heerdegen To: bug-gnu-emacs@gnu.org Subject: 25.1; Bytecode returns nil instead of expected closure Date: Sun, 07 Aug 2016 01:16:50 +0200 Message-ID: <877fbtqyhp.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:qhFm9gMKRp6+K0t7eIzeK4MrtjCNkT59e6O3LJOB3RhkTVA7yaJ wt6yH1+qwvn7ZzxEaPag4oQGEwt5RMzbEpmawQCjOq/AD4VX4+GpBlvpekGna2GOWANTLvl Tw96XEqn+a3vlrqFliCsOV5L2ajHPaZEzYvPuxdgB59WIuBN39eKNI8OgJV0CClp4naOLtY n0N2zu2ocjpnhHcToqpaA== X-UI-Out-Filterresults: notjunk:1;V01:K0:t3YUraWon/w=:SKYOmajKzHhOF6BxpJLhUx va/bl2DrinLqzJeuUR+EN0v7V8sgh0bXxTkMTEjJUIcfGx8jlhHdZnoqt3l3Jl9fdPZjWhC6S lxRfcskTNuqM5rjzgBjFIZH4TGwECSXylvQdbnUyT3XS5yUfWEqGC4D25aTlYImosajaM7LiE +dN28Vx2zxUMxkyCTStxKInxxJpA7a4H2Ap9MUiUxxS1i/UqEbz4X2eGUv0CzR5N5j504QIcv T1uBADuB/Pp2bMUVrBTZN9P7TPfrhumT3PvXNccZKru9/vY1iSZTIinMRq6gHfDcNJdlKrNBq YkoV/xKmXvPcKt47JMa/TPTYQ/dhMZsJsfvsK7J5tXtL4lJyKxAXL5BtbTyO3RMOUzkvijtvl cSYG67vFFqv2tX0+/M1RrHBMcOEyMQHFXEgQ2ziTNh7fYq58sP5NW/MGiTaR0djEN79DnWGD7 NhPAIelR1U/DVb840v3a8eNpRSmzViyfiUhjALb9Gm2jQvq/UizS2if65GtTQyLRmQvoMh/YD jviZFZyoQeJyZyGCmEVx70Hl65JF6DTK9n9vnMijQnnjOBFBp0KKg809YM8pgHXbFNXmJTyez U+TIciHdPR7sS4FHzJyMyCvbyBlZcFiOkickFVDIaRvKvIOxQ0XDeD2trFK8rO/u8MU1N3z22 Rdt/zMOAmV9C1u/6tDP6luh5CX6+ciXTzQqBuu76xb6+w0Tj3G0whsWP3y0U9I5XOWzmNLpA2 9Pp4ojAouyWi4I//8Q/NA1B2PH3GiquxOSuEs1RDD5gDHcaad5XgJQ/rCxCva2oJOCQVbAouV K6cLaOo X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit Cc: Alex Vong X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) Hello, eval this defun: (defun test () (let ((my-cool-fun 'dummy)) (let ((my-cool-fun (let ((calculate (lambda () 1))) (lambda () (setq my-cool-fun calculate)))) (return-my-cool-fun (lambda () my-cool-fun))) (funcall my-cool-fun) (funcall return-my-cool-fun)))) (test) evals to a closure as expected. Compile the defun and load it. Then, (test) -> nil which is wrong. Found in https://lists.gnu.org/archive/html/help-gnu-emacs/2016-08/msg00038.html Thanks, Michael. In GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.20.6) of 2016-08-04 built on drachen Repository revision: 72221f51439d666d54f5d147f00ecdbb3778ab1b Windowing system distributor 'The X.Org Foundation', version 11.0.11804000 System Description: Debian GNU/Linux testing (stretch) Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GSETTINGS NOTIFY LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 07 05:01:59 2016 Received: (at 24171) by debbugs.gnu.org; 7 Aug 2016 09:01:59 +0000 Received: from localhost ([127.0.0.1]:58329 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWJy3-0004pO-D8 for submit@debbugs.gnu.org; Sun, 07 Aug 2016 05:01:59 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:46883) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWJy1-0004pE-9i for 24171@debbugs.gnu.org; Sun, 07 Aug 2016 05:01:57 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3s6ZKw1Jtxz3hjS7; Sun, 7 Aug 2016 11:01:55 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3s6ZKv2GMDzvkQW; Sun, 7 Aug 2016 11:01:55 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id 2G4W00sY34wy; Sun, 7 Aug 2016 11:01:54 +0200 (CEST) X-Auth-Info: W6gpn/X5oeXJ70WEkPcA296dzM16OnUu9WvWHgHwizjiHiHuSKCSqvYYeeZ0T40l Received: from linux.local (ppp-88-217-6-113.dynamic.mnet-online.de [88.217.6.113]) by mail.mnet-online.de (Postfix) with ESMTPA; Sun, 7 Aug 2016 11:01:54 +0200 (CEST) Received: by linux.local (Postfix, from userid 501) id 8F1161E530E; Sun, 7 Aug 2016 11:01:51 +0200 (CEST) From: Andreas Schwab To: Michael Heerdegen Subject: Re: bug#24171: 25.1; Bytecode returns nil instead of expected closure References: <877fbtqyhp.fsf@web.de> X-Yow: Those aren't WINOS--that's my JUGGLER, my AERIALIST, my SWORD SWALLOWER, and my LATEX NOVELTY SUPPLIER!! Date: Sun, 07 Aug 2016 11:01:50 +0200 In-Reply-To: <877fbtqyhp.fsf@web.de> (Michael Heerdegen's message of "Sun, 07 Aug 2016 01:16:50 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 24171 Cc: 24171@debbugs.gnu.org, Alex Vong X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Michael Heerdegen writes: > eval this defun: > > (defun test () > (let ((my-cool-fun 'dummy)) > (let ((my-cool-fun > (let ((calculate (lambda () 1))) > (lambda () (setq my-cool-fun calculate)))) > (return-my-cool-fun (lambda () my-cool-fun))) > (funcall my-cool-fun) > (funcall return-my-cool-fun)))) > > (test) evals to a closure as expected. ELISP> (test) *** Eval error *** Symbol’s value as variable is void: calculate Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 07 05:30:49 2016 Received: (at submit) by debbugs.gnu.org; 7 Aug 2016 09:30:49 +0000 Received: from localhost ([127.0.0.1]:58341 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWKPx-0005Ux-9i for submit@debbugs.gnu.org; Sun, 07 Aug 2016 05:30:49 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58597) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWKPw-0005Uk-6t for submit@debbugs.gnu.org; Sun, 07 Aug 2016 05:30:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWKPq-0001A2-Cg for submit@debbugs.gnu.org; Sun, 07 Aug 2016 05:30:43 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:54255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWKPq-00019s-8e for submit@debbugs.gnu.org; Sun, 07 Aug 2016 05:30:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWKPo-0008Il-0m for bug-gnu-emacs@gnu.org; Sun, 07 Aug 2016 05:30:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWKPj-000178-N3 for bug-gnu-emacs@gnu.org; Sun, 07 Aug 2016 05:30:38 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:61246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWKPj-000174-CG for bug-gnu-emacs@gnu.org; Sun, 07 Aug 2016 05:30:35 -0400 Received: from [18.189.62.146] ([18.189.62.146]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0LpOJJ-1b0XpU2pzJ-00f9D0; Sun, 07 Aug 2016 11:30:33 +0200 Subject: Re: bug#24171: 25.1; Bytecode returns nil instead of expected closure To: bug-gnu-emacs@gnu.org, Andreas Schwab References: <877fbtqyhp.fsf@web.de> From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= Message-ID: <2cd05bdc-37df-d215-0154-6d67636e486f@gmail.com> Date: Sun, 7 Aug 2016 05:30:31 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wQ0EFsWHTgCTuNui4gpHtv70qP5TAJ7iQ" X-Provags-ID: V03:K0:vDCJM2D4zaRTPR1xU0U95BCscRtmJJCxrEc1kt09szNkpu74Lxs Zj1npurPcoTd/BqA5eRv7n1/OcbLKi9mzPpwMy8PQjEfwXAO/AJpGJgD2XPfA7kMPYKhzbD +93iqgVY4u6ywp+tCudLMG2/Ph+oViOkmkEFqw/xJEQorO1te9qGk2Xk84P2b6WTSLwEKDf VGjEZiMpdEiYXUn81J02Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:8Tb2IjNE0vc=:oE7xejanSgriuY+eOV4vwg trNnIeMgQFAyLMuURWjw5EvEL0v8+z+kGB+mfgaXmwsHbTSkGcfsenOuXgUCv4CHJ9h7LL9HY 8sIE0Wgb+qu1PHTgg4yJR8VuH6I6PWbnHed0SJb0HSKpgd2+0z/BrGajXjEG+txCS8W8VAy/U x6tbzLUIATvxDyHHEt1cIGfYAQipaK+Y996/bJtdh2Kyha7nFw3p4i9J8cJc9id4IH8xHpUCd XfQq8FwjfEnGpn76xU3crbYRR15vFZv2n1sYOyZki5nqo4XhSaRn4yVNta3pTakExU6rGuM3Z k/cjEXwjGLTHlrE9uocZGYLqUn+ANMPBCSKZi0B+IS+BVTSDe8SmhmKgsHE5k9tgAbuLASHk9 ADlO+GE8S8j4bpDIAKj6e2SqGlfl4cvvXyS2+RPoeJQNO4IjD8buoZikhXzDcHcombqyJleFA N6fdp/Of+Ek0bL3IV+jWHbKk1PV1yxFI7IPeiKIuvd7ja36sKy3NUOP0iHdL3R2nbSDcqycCT g/n1MLczz1hI2fo8kXBpELoXSYj8xG/W0aA2xtx3ncwdtBcBg9/4ksZuhB2Fpp3t9W5TA4PPi izIHGr5tNlWbltc0ZY+Vt+ukNb/jg4T/8zfWOpLxHBB7U/QSZnMHtF41igQIo8rEbQu1XM+pi +dT1XxkIiLzaGpteXCzGnZ/1iqueSVv0Gn0Z35pxns+23p9LXr67I5DyIy8OUNCTPh8Y= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --wQ0EFsWHTgCTuNui4gpHtv70qP5TAJ7iQ Content-Type: multipart/mixed; boundary="LE6Ag3IlbqKs1mSwaRdRoUGKgM7j7H44R" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: bug-gnu-emacs@gnu.org, Andreas Schwab Message-ID: <2cd05bdc-37df-d215-0154-6d67636e486f@gmail.com> Subject: Re: bug#24171: 25.1; Bytecode returns nil instead of expected closure References: <877fbtqyhp.fsf@web.de> In-Reply-To: --LE6Ag3IlbqKs1mSwaRdRoUGKgM7j7H44R Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2016-08-07 05:01, Andreas Schwab wrote: > Michael Heerdegen writes: >=20 >> eval this defun: >> >> (defun test () >> (let ((my-cool-fun 'dummy)) >> (let ((my-cool-fun >> (let ((calculate (lambda () 1))) >> (lambda () (setq my-cool-fun calculate)))) >> (return-my-cool-fun (lambda () my-cool-fun))) >> (funcall my-cool-fun) >> (funcall return-my-cool-fun)))) >> >> (test) evals to a closure as expected. >=20 > ELISP> (test) > *** Eval error *** Symbol=E2=80=99s value as variable is void: calcula= te I can reproduce this. Andreas, are you missing ;; -*- lexical-binding: t;= -*- ? Cl=C3=A9ment. --LE6Ag3IlbqKs1mSwaRdRoUGKgM7j7H44R-- --wQ0EFsWHTgCTuNui4gpHtv70qP5TAJ7iQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXpv+3AAoJEPqg+cTm90wjdecQALOyxFDzUyZITbAb+otT8MRq mBGwuF3pD6tmcOVq3xitZ1TvTKgYQRN6xRc5XjTBawEN/XWxaouRBjXBndKFSwXv UQWAhgUBZFOGVHgcTKPzc4mxAwks8jA+C3CKkwH6z8kk0bipTpca5dpr0mLoImTW 3e9ow1kge671T2Lp81k7/BpvA1Y4uaOK49AOjOuDjIIVWSXki8E+3ZC/czIZW4tF E4MYrExEY+hSly0mdXML5ghLqwAcs9Ix4WfMFejOlWVCl4e4dFfJUV/2i9J6wRYj jmGsPe3rdLy24AN4mtMOYAJKoR2cuMAkA2/32SFMMRwBpQ3mTVTjw+3RZJ8Q10Rl tSz+jOEcFoH99L6bv+zQDB0iws5VTQAG/TWpuAkbJnKKYgXEQ+2+r41JE5LeEQsE 3yxlTO1ukjGt93zaa65+hkJFqZR35j1w2Mkq3L4vYFpAnQXRKmAYfb630rTpzIwB NOLZyK8tC2mDfKRkM/HkyaUokO7/yR4nKYwALV5n+1tFb73n7jwarNhvzSK527U+ BlHt8k8yXmG76JsLOTCKvOvtkLcvDKkEOAh3xqj1b0C+2/19Q7fVwsrsz5smBD+N SC4Z+lyTez7+oUSFFy543fVmNS6SKTJXvGapY7karBLkrb5DZNHj2jNIrrN1kFyn tQrDICdAuCxIXm2+Iahu =19RQ -----END PGP SIGNATURE----- --wQ0EFsWHTgCTuNui4gpHtv70qP5TAJ7iQ-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 07 07:25:10 2016 Received: (at submit) by debbugs.gnu.org; 7 Aug 2016 11:25:10 +0000 Received: from localhost ([127.0.0.1]:58410 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWMCc-0008Mj-3r for submit@debbugs.gnu.org; Sun, 07 Aug 2016 07:25:10 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42025) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWMCa-0008MY-VL for submit@debbugs.gnu.org; Sun, 07 Aug 2016 07:25:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWMCU-0007RD-VD for submit@debbugs.gnu.org; Sun, 07 Aug 2016 07:25:03 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:37497) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWMCU-0007QW-Rq for submit@debbugs.gnu.org; Sun, 07 Aug 2016 07:25:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWMCS-0004BM-GR for bug-gnu-emacs@gnu.org; Sun, 07 Aug 2016 07:25:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWMCN-0007QH-Ld for bug-gnu-emacs@gnu.org; Sun, 07 Aug 2016 07:24:59 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:59181) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWMCN-0007Q4-F6 for bug-gnu-emacs@gnu.org; Sun, 07 Aug 2016 07:24:55 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3s6dVr5QqSz3hjQq; Sun, 7 Aug 2016 13:24:52 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3s6dVr5DtZzvkMF; Sun, 7 Aug 2016 13:24:52 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id Hl-yaoLdlq_j; Sun, 7 Aug 2016 13:24:52 +0200 (CEST) X-Auth-Info: 1/k5G/3EFMPAiUUR0zA4XhEhVIru0yFGDsYxsjwjmVhKYft/qrfQIGIil3JEuMmq Received: from igel.home (ppp-88-217-6-113.dynamic.mnet-online.de [88.217.6.113]) by mail.mnet-online.de (Postfix) with ESMTPA; Sun, 7 Aug 2016 13:24:52 +0200 (CEST) Received: by igel.home (Postfix, from userid 1000) id B58242C36D0; Sun, 7 Aug 2016 13:24:51 +0200 (CEST) From: Andreas Schwab To: =?utf-8?Q?Cl=C3=A9ment?= Pit--Claudel Subject: Re: bug#24171: 25.1; Bytecode returns nil instead of expected closure References: <877fbtqyhp.fsf@web.de> <2cd05bdc-37df-d215-0154-6d67636e486f@gmail.com> X-Yow: Uh-oh!! I'm having TOO MUCH FUN!! Date: Sun, 07 Aug 2016 13:24:51 +0200 In-Reply-To: <2cd05bdc-37df-d215-0154-6d67636e486f@gmail.com> (=?utf-8?Q?=22Cl=C3=A9ment?= Pit--Claudel"'s message of "Sun, 7 Aug 2016 05:30:31 -0400") Message-ID: <87wpjs95z0.fsf@linux-m68k.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) On So, Aug 07 2016, Clément Pit--Claudel wrote: > On 2016-08-07 05:01, Andreas Schwab wrote: >> Michael Heerdegen writes: >> >>> eval this defun: >>> >>> (defun test () >>> (let ((my-cool-fun 'dummy)) >>> (let ((my-cool-fun >>> (let ((calculate (lambda () 1))) >>> (lambda () (setq my-cool-fun calculate)))) >>> (return-my-cool-fun (lambda () my-cool-fun))) >>> (funcall my-cool-fun) >>> (funcall return-my-cool-fun)))) >>> >>> (test) evals to a closure as expected. >> >> ELISP> (test) >> *** Eval error *** Symbol’s value as variable is void: calculate > > I can reproduce this. Andreas, are you missing ;; -*- lexical-binding: t; -*- ? I was following the instructions. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 07 10:44:40 2016 Received: (at 24171) by debbugs.gnu.org; 7 Aug 2016 14:44:40 +0000 Received: from localhost ([127.0.0.1]:59163 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWPJf-00083N-Rm for submit@debbugs.gnu.org; Sun, 07 Aug 2016 10:44:40 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:51899) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWPJe-000838-An for 24171@debbugs.gnu.org; Sun, 07 Aug 2016 10:44:39 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AxFgA731xV/2/xd0tcgxCEAoVVu0CHSwQCAoE8OxIBAQEBAQEBgQpBBYNdAQEEViMQCzQSFBgNJIg/zyMBAQEBBgEBAQEeizqFBQeELQEEi0SOKZlSgUUjgWaCLiKCeAEBAQ X-IPAS-Result: A0AxFgA731xV/2/xd0tcgxCEAoVVu0CHSwQCAoE8OxIBAQEBAQEBgQpBBYNdAQEEViMQCzQSFBgNJIg/zyMBAQEBBgEBAQEeizqFBQeELQEEi0SOKZlSgUUjgWaCLiKCeAEBAQ X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="250488116" Received: from 75-119-241-111.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([75.119.241.111]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Aug 2016 10:44:32 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 5C0D7AE080; Sun, 7 Aug 2016 10:44:31 -0400 (EDT) From: Stefan Monnier To: Michael Heerdegen Subject: Re: bug#24171: 25.1; Bytecode returns nil instead of expected closure Message-ID: References: <877fbtqyhp.fsf@web.de> Date: Sun, 07 Aug 2016 10:44:31 -0400 In-Reply-To: <877fbtqyhp.fsf@web.de> (Michael Heerdegen's message of "Sun, 07 Aug 2016 01:16:50 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 24171 Cc: 24171@debbugs.gnu.org, Alex Vong X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > (defun test () > (let ((my-cool-fun 'dummy)) > (let ((my-cool-fun > (let ((calculate (lambda () 1))) > (lambda () (setq my-cool-fun calculate)))) > (return-my-cool-fun (lambda () my-cool-fun))) > (funcall my-cool-fun) > (funcall return-my-cool-fun)))) Good catch. It's a bug in cconv.el in the case where it decides to use lambda-lifting. It tries to handle such name-capture (search for "(when (memq var new-extend)" in cconv.el to see where) but doesn't catch the above case. Don't have a fix yet. For the above test case, you can circumvent the bug by swapping the order of return-my-cool-fun and my-cool-fun in the let binding. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 07 18:57:59 2016 Received: (at 24171) by debbugs.gnu.org; 7 Aug 2016 22:57:59 +0000 Received: from localhost ([127.0.0.1]:59325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWX14-0004JA-QI for submit@debbugs.gnu.org; Sun, 07 Aug 2016 18:57:58 -0400 Received: from mout.web.de ([217.72.192.78]:62213) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWX12-0004Ix-Rv for 24171@debbugs.gnu.org; Sun, 07 Aug 2016 18:57:57 -0400 Received: from drachen.dragon ([94.217.122.157]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0LxOHm-1bC3Tl2j1O-0170lC; Mon, 08 Aug 2016 00:57:47 +0200 From: Michael Heerdegen To: Andreas Schwab Subject: Re: bug#24171: 25.1; Bytecode returns nil instead of expected closure References: <877fbtqyhp.fsf@web.de> Date: Mon, 08 Aug 2016 00:57:45 +0200 In-Reply-To: (Andreas Schwab's message of "Sun, 07 Aug 2016 11:01:50 +0200") Message-ID: <87wpjsgpau.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K0:7A9/0km5rC7mXejxpb/bB0QI6dFRh4OOVMN+/x0E6ym7oz4ss0C xxoklX8CgmO3dCYkou5QzHi/8F13Pq3qXybCMBuSgELeaDvzX2zv4mTqpQ6LZqKGOwPpZXu PYN4IvtXxEjpw/jmUXcFpN83URbjt+BH/t/f8PdW307qUEp6GjmlyMGEt6sQ/rw4s6I1oFo gk0DpwATptWb/iRWuUADQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:M882Yrbc78Y=:Q/3UKPJNv4HjwABEdR45Af HDY5ce4zHbz3RIYCQXAwGeYqeW/vjbZYoD1ZwXFa6wHIYa/5rByzXruzmhaz9ghQ83Wp7YADs b1xVLDpCw2LZdr//sIu7hXwL+2ErNGIDFTIBt3brPtZS6dmtJfnvFkIOaSOb+hutsk3CKZqIw mqN4GXzUmDfWkah2PcKjAshY34vGGdqMT48PtiBxsJM/9VorCzlu1L6U/ECPwXczOoYE0/Spn owsh1Z+2Y8d29bCdgLUL4pWyWeu/A2CCZJUyQrACjFoDia02h0Cn0YVFQk4zHLRWZlw0L7DQv N9fxoDCab6eZWL5q1aO/fTm1IOYzDG4XQbp3NkYsXhTOViKe4PGfoGSo74jhUJmlFHEM0EK7b 9XnVFjWZokCjhWJckDZ75smS8T+ysFMunAhm/vfO/5wVgPCVt3KZlVXc+ycZDCMGfyHJWUzfJ ouK36Mci5lfwoGZ9IKyQGDH5w5yBhhmORmm2hHtoGfdF0GLJKmGkEscRfsmbuphH93QrJOFcu kPoR+wmDVywE4oYrDoXfMDXJdbM0Dcr6TFnO1idEWYaSTO9AeQpKlfZAg/SsvDaVekIEeJQip ZnCyfG6l6CIQa++8IflgWOb2uovGwv+vP6du5Akdd5GXenvgjjtaPoFIz3L5DjGJ4SpGZQaia ZS5iMZilIhwkuiDkIDUe6s+l0m3kz66ZVJpfEIGMS8lug+cWItKU+uY2+U9h3IsMPEl5F6ypx AesYz2cqLYBdkxcYfUe6z1W7x25rG2DMmBAGURl1naWGP2foKu/a5X25naB0InPXLvpXInp1F CKtDk1I X-Spam-Score: -1.2 (-) X-Debbugs-Envelope-To: 24171 Cc: 24171@debbugs.gnu.org, Alex Vong X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) Andreas Schwab writes: > ELISP> (test) > *** Eval error *** Symbol=E2=80=99s value as variable is void: calculate Eh, sorry, forgot to mention that the recipe needs lexical-binding. Thanks, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 07 22:04:24 2016 Received: (at 24171) by debbugs.gnu.org; 8 Aug 2016 02:04:24 +0000 Received: from localhost ([127.0.0.1]:59390 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWZvU-00008Q-6g for submit@debbugs.gnu.org; Sun, 07 Aug 2016 22:04:24 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:52509) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWZvR-000083-TC for 24171@debbugs.gnu.org; Sun, 07 Aug 2016 22:04:22 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0A7FgA731xV/2/xd0tcgxCEAk6FB7tAhH6CTQQCAoE8OhMBAQEBAQEBgQpBBYNdAQEEIzMjEAsaAhgOAgIUGA0kiD+rDKQXAQEBBwIggSGJF4EChFIzB4JogUUFi0STU4NrkD2BRSOBZiQcgW4igngBAQE X-IPAS-Result: A0A7FgA731xV/2/xd0tcgxCEAk6FB7tAhH6CTQQCAoE8OhMBAQEBAQEBgQpBBYNdAQEEIzMjEAsaAhgOAgIUGA0kiD+rDKQXAQEBBwIggSGJF4EChFIzB4JogUUFi0STU4NrkD2BRSOBZiQcgW4igngBAQE X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="250529238" Received: from 75-119-241-111.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([75.119.241.111]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Aug 2016 22:04:15 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 39065AE080; Sun, 7 Aug 2016 22:04:15 -0400 (EDT) From: Stefan Monnier To: Michael Heerdegen Subject: Re: bug#24171: 25.1; Bytecode returns nil instead of expected closure Message-ID: References: <877fbtqyhp.fsf@web.de> Date: Sun, 07 Aug 2016 22:04:15 -0400 In-Reply-To: <877fbtqyhp.fsf@web.de> (Michael Heerdegen's message of "Sun, 07 Aug 2016 01:16:50 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 24171 Cc: 24171@debbugs.gnu.org, Alex Vong X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) You can test the problem with: M-: (cconv-closure-convert '(let ((x 1)) (let ((x 2) (f (function (lambd= a (y) (+ y x))))) (funcall f x)))) where you'll see that the lambda-lifting used by cconv.el is too naive and uses `x' to refer to the outer variable without noticing that that variable is shadowed by the inner `x'. The patch below should fix it and is the best I can come up with so far. Can you confirm that it fixes the original problem? The bug was filed against 25.1, so I have (very lightly) tested the patch against the emacs-25 branch, but since this bug dates back to Emacs-24.1, I think there's no hurry to fix it. IOW I intend to install it into master. Please holler if you think it deserves to be on emacs-25. Stefan diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el index 50b1fe3..2d68066 100644 --- a/lisp/emacs-lisp/cconv.el +++ b/lisp/emacs-lisp/cconv.el @@ -253,6 +253,32 @@ Returns a form where all lambdas don't have any free v= ariables." `(internal-make-closure ,args ,envector ,docstring . ,body-new))))) =20 +(defun cconv--remap-llv (new-env var closedsym) + ;; In a case such as: + ;; (let* ((fun (lambda (x) (+ x y))) (y 1)) (funcall fun 1)) + ;; A naive lambda-lifting would return + ;; (let* ((fun (lambda (y x) (+ x y))) (y 1)) (funcall fun y 1)) + ;; Where the external `y' is mistakenly captured by the inner one. + ;; So when we detect that case, we rewrite it to: + ;; (let* ((closed-y y) (fun (lambda (y x) (+ x y))) (y 1)) + ;; (funcall fun closed-y 1)) + ;; We do that even if there's no `funcall' that uses `fun' in the scope + ;; where `y' is shadowed by another variable because, to treat + ;; this case better, we'd need to traverse the tree one more time to + ;; collect this data, and I think that it's not worth it. +(mapcar (lambda (mapping) + (if (not (eq (cadr mapping) 'apply-partially)) + mapping + (cl-assert (eq (car mapping) (nth 2 mapping))) + `(,(car mapping) + apply-partially + ,(car mapping) + ,@(mapcar (lambda (arg) + (if (eq var arg) + closedsym arg)) + (nthcdr 3 mapping))))) + new-env)) + (defun cconv-convert (form env extend) ;; This function actually rewrites the tree. "Return FORM with all its lambdas changed so they are closed. @@ -350,34 +376,13 @@ places where they originally did not directly appear." (if (assq var new-env) (push `(,var) new-env)) (cconv-convert value env extend))))) =20 - ;; The piece of code below letbinds free variables of a =CE=BB-= lifted - ;; function if they are redefined in this let, example: - ;; (let* ((fun (lambda (x) (+ x y))) (y 1)) (funcall fun 1)) - ;; Here we can not pass y as parameter because it is redefined. - ;; So we add a (closed-y y) declaration. We do that even if the - ;; function is not used inside this let(*). The reason why we - ;; ignore this case is that we can't "look forward" to see if t= he - ;; function is called there or not. To treat this case better = we'd - ;; need to traverse the tree one more time to collect this data= , and - ;; I think that it's not worth it. - (when (memq var new-extend) - (let ((closedsym - (make-symbol (concat "closed-" (symbol-name var))))) - (setq new-env - (mapcar (lambda (mapping) - (if (not (eq (cadr mapping) 'apply-partiall= y)) - mapping - (cl-assert (eq (car mapping) (nth 2 mappi= ng))) - `(,(car mapping) - apply-partially - ,(car mapping) - ,@(mapcar (lambda (arg) - (if (eq var arg) - closedsym arg)) - (nthcdr 3 mapping))))) - new-env)) - (setq new-extend (remq var new-extend)) - (push closedsym new-extend) + (when (and (eq letsym 'let*) (memq var new-extend)) + ;; One of the lambda-lifted vars is shadowed, so add + ;; a reference to the outside binding and arrange to use + ;; that reference. + (let ((closedsym (make-symbol (format "closed-%s" var)))) + (setq new-env (cconv--remap-llv new-env var closedsym)) + (setq new-extend (cons closedsym (remq var new-extend))) (push `(,closedsym ,var) binders-new))) =20 ;; We push the element after redefined free variables are @@ -390,6 +395,21 @@ places where they originally did not directly appear." (setq extend new-extend)) )) ; end of dolist over binders =20 + (when (not (eq letsym 'let*)) + ;; We can't do the cconv--remap-llv at the same place for let and + ;; let* because in the case of `let', the shadowing may occur + ;; before we know that the var will be in `new-extend' (bug#24171= ). + (dolist (binder binders-new) + (when (memq (car-safe binder) new-extend) + ;; One of the lambda-lifted vars is shadowed, so add + ;; a reference to the outside binding and arrange to use + ;; that reference. + (let* ((var (car-safe binder)) + (closedsym (make-symbol (format "closed-%s" var)))) + (setq new-env (cconv--remap-llv new-env var closedsym)) + (setq new-extend (cons closedsym (remq var new-extend))) + (push `(,closedsym ,var) binders-new))))) + `(,letsym ,(nreverse binders-new) . ,(mapcar (lambda (form) (cconv-convert From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 08 06:39:10 2016 Received: (at 24171) by debbugs.gnu.org; 8 Aug 2016 10:39:10 +0000 Received: from localhost ([127.0.0.1]:59574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWhxd-00077g-RG for submit@debbugs.gnu.org; Mon, 08 Aug 2016 06:39:10 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:36551) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWhxc-00077T-MB for 24171@debbugs.gnu.org; Mon, 08 Aug 2016 06:39:09 -0400 Received: by mail-pa0-f66.google.com with SMTP id ez1so23792180pab.3 for <24171@debbugs.gnu.org>; Mon, 08 Aug 2016 03:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=r1Z775zYgjbgL7e0I8M01RDjfhJ64kjQHyRr4k/Pmgo=; b=iThguY16JyoXrdUmmoFDkm+eYf3JH0iolJ2wXYvVGBQNZqCspk+4CnGqISpg56uIn7 M1PM2WubN+ff9I9AHIcE4HeL4d7pHeyUa3edjXSkQsAdcldNeMhiHRPJ209ruhAl1OL3 6//pni70ofzSH4NuU2hWaO4xtAw/arW+IfuLuGnmLXGqeIYnfKEyyoar3SzM3Pn3puc2 R/VkZPLEkYU2gIYztIvEfMSsmF0lO7m0kkQALpwL+n1iO5WYkVkoCdT1uMiqef8VCOn4 P1LzbNLenziPS7t3vugAtYNu/sTSVL6+aLdD42Ft65rGXLLL3EFT1IQT4LjNwWp0hfIP CSOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=r1Z775zYgjbgL7e0I8M01RDjfhJ64kjQHyRr4k/Pmgo=; b=FcU6EA8oSrGYE79Vfifpz0KlDfiuCVv9C+jOGFgKe95d3DE9O8oHREWTGan3KTQgpL Pj7LAjpKVAEGIrCs6Kv9fXNKTRvtAcazPBayjQXrPpl5lBvtEFbpLR7CRdsAam9O0hfW wN7nCzpMnxVIcHTsuGojGJDRihtoS4IEnK50tbluDvytkML8vA6bzCzH3kXQGj9BaUEH 9k8KOeAZqxfEHqJDkyb5ZoFAYEGA+ySn+PeO/UuxUftQV7Ho1iAAqBKh7yLisjLv1B4H eORxVyz5oHKNP793J56jCkmRNhMJgHyGzF3xE0PNNPBJpY3UKi00r8TgemKKmC4DLuD1 oQCw== X-Gm-Message-State: AEkoouuZI5iRYm+4ugCx7+LtnYzxZpkLttZDXYpy5d8RAZyhtT9BdBej50DFafofLJ2LJw== X-Received: by 10.66.127.10 with SMTP id nc10mr88337030pab.109.1470652742710; Mon, 08 Aug 2016 03:39:02 -0700 (PDT) Received: from debian (1-64-207-052.static.netvigator.com. [1.64.207.52]) by smtp.gmail.com with ESMTPSA id 191sm46936965pfx.68.2016.08.08.03.39.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Aug 2016 03:39:01 -0700 (PDT) From: Alex Vong To: Stefan Monnier Subject: Re: bug#24171: 25.1; Bytecode returns nil instead of expected closure References: <877fbtqyhp.fsf@web.de> Date: Mon, 08 Aug 2016 18:38:53 +0800 In-Reply-To: (Stefan Monnier's message of "Sun, 07 Aug 2016 22:04:15 -0400") Message-ID: <87twevmtoi.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.4 (/) X-Debbugs-Envelope-To: 24171 Cc: Michael Heerdegen , 24171@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) Hi, Stefan Monnier writes: > You can test the problem with: > > M-: (cconv-closure-convert '(let ((x 1)) (let ((x 2) (f (function (lam= bda (y) (+ y x))))) (funcall f x)))) > > where you'll see that the lambda-lifting used by cconv.el is too naive > and uses `x' to refer to the outer variable without noticing that that > variable is shadowed by the inner `x'. > > The patch below should fix it and is the best I can come up with so far. > > Can you confirm that it fixes the original problem? > Yes, this fixes the original problem. (https://lists.gnu.org/archive/html/help-gnu-emacs/2016-08/msg00038.html) The test is performed on master branch with patch applied. > The bug was filed against 25.1, so I have (very lightly) tested the > patch against the emacs-25 branch, but since this bug dates back to > Emacs-24.1, I think there's no hurry to fix it. > > IOW I intend to install it into master. Please holler if you think it > deserves to be on emacs-25. > I have no problem with this. > > Stefan > > > > diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el > index 50b1fe3..2d68066 100644 > --- a/lisp/emacs-lisp/cconv.el > +++ b/lisp/emacs-lisp/cconv.el > @@ -253,6 +253,32 @@ Returns a form where all lambdas don't have any free= variables." > `(internal-make-closure > ,args ,envector ,docstring . ,body-new))))) >=20=20 > +(defun cconv--remap-llv (new-env var closedsym) > + ;; In a case such as: > + ;; (let* ((fun (lambda (x) (+ x y))) (y 1)) (funcall fun 1)) > + ;; A naive lambda-lifting would return > + ;; (let* ((fun (lambda (y x) (+ x y))) (y 1)) (funcall fun y 1)) > + ;; Where the external `y' is mistakenly captured by the inner one. > + ;; So when we detect that case, we rewrite it to: > + ;; (let* ((closed-y y) (fun (lambda (y x) (+ x y))) (y 1)) > + ;; (funcall fun closed-y 1)) > + ;; We do that even if there's no `funcall' that uses `fun' in the scope > + ;; where `y' is shadowed by another variable because, to treat > + ;; this case better, we'd need to traverse the tree one more time to > + ;; collect this data, and I think that it's not worth it. > +(mapcar (lambda (mapping) > + (if (not (eq (cadr mapping) 'apply-partially)) > + mapping > + (cl-assert (eq (car mapping) (nth 2 mapping))) > + `(,(car mapping) > + apply-partially > + ,(car mapping) > + ,@(mapcar (lambda (arg) > + (if (eq var arg) > + closedsym arg)) > + (nthcdr 3 mapping))))) > + new-env)) > + > (defun cconv-convert (form env extend) > ;; This function actually rewrites the tree. > "Return FORM with all its lambdas changed so they are closed. > @@ -350,34 +376,13 @@ places where they originally did not directly appea= r." > (if (assq var new-env) (push `(,var) new-env)) > (cconv-convert value env extend))))) >=20=20 > - ;; The piece of code below letbinds free variables of a =CE= =BB-lifted > - ;; function if they are redefined in this let, example: > - ;; (let* ((fun (lambda (x) (+ x y))) (y 1)) (funcall fun 1)) > - ;; Here we can not pass y as parameter because it is redefine= d. > - ;; So we add a (closed-y y) declaration. We do that even if = the > - ;; function is not used inside this let(*). The reason why we > - ;; ignore this case is that we can't "look forward" to see if= the > - ;; function is called there or not. To treat this case bette= r we'd > - ;; need to traverse the tree one more time to collect this da= ta, and > - ;; I think that it's not worth it. > - (when (memq var new-extend) > - (let ((closedsym > - (make-symbol (concat "closed-" (symbol-name var))))) > - (setq new-env > - (mapcar (lambda (mapping) > - (if (not (eq (cadr mapping) 'apply-partia= lly)) > - mapping > - (cl-assert (eq (car mapping) (nth 2 map= ping))) > - `(,(car mapping) > - apply-partially > - ,(car mapping) > - ,@(mapcar (lambda (arg) > - (if (eq var arg) > - closedsym arg)) > - (nthcdr 3 mapping))))) > - new-env)) > - (setq new-extend (remq var new-extend)) > - (push closedsym new-extend) > + (when (and (eq letsym 'let*) (memq var new-extend)) > + ;; One of the lambda-lifted vars is shadowed, so add > + ;; a reference to the outside binding and arrange to use > + ;; that reference. > + (let ((closedsym (make-symbol (format "closed-%s" var)))) > + (setq new-env (cconv--remap-llv new-env var closedsym)) > + (setq new-extend (cons closedsym (remq var new-extend))) > (push `(,closedsym ,var) binders-new))) >=20=20 > ;; We push the element after redefined free variables are > @@ -390,6 +395,21 @@ places where they originally did not directly appear= ." > (setq extend new-extend)) > )) ; end of dolist over binders >=20=20 > + (when (not (eq letsym 'let*)) > + ;; We can't do the cconv--remap-llv at the same place for let a= nd > + ;; let* because in the case of `let', the shadowing may occur > + ;; before we know that the var will be in `new-extend' (bug#241= 71). > + (dolist (binder binders-new) > + (when (memq (car-safe binder) new-extend) > + ;; One of the lambda-lifted vars is shadowed, so add > + ;; a reference to the outside binding and arrange to use > + ;; that reference. > + (let* ((var (car-safe binder)) > + (closedsym (make-symbol (format "closed-%s" var)))) > + (setq new-env (cconv--remap-llv new-env var closedsym)) > + (setq new-extend (cons closedsym (remq var new-extend))) > + (push `(,closedsym ,var) binders-new))))) > + > `(,letsym ,(nreverse binders-new) > . ,(mapcar (lambda (form) > (cconv-convert Thanks, Alex From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 08 23:26:43 2016 Received: (at 24171) by debbugs.gnu.org; 9 Aug 2016 03:26:43 +0000 Received: from localhost ([127.0.0.1]:60572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWxgg-0003RW-Qh for submit@debbugs.gnu.org; Mon, 08 Aug 2016 23:26:42 -0400 Received: from mout.web.de ([217.72.192.78]:57336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWxge-0003RG-BE for 24171@debbugs.gnu.org; Mon, 08 Aug 2016 23:26:41 -0400 Received: from drachen.dragon ([188.98.97.14]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MRlED-1bdF3X1iBN-00Sz78; Tue, 09 Aug 2016 05:26:30 +0200 From: Michael Heerdegen To: Stefan Monnier Subject: Re: bug#24171: 25.1; Bytecode returns nil instead of expected closure References: <877fbtqyhp.fsf@web.de> Date: Tue, 09 Aug 2016 05:26:27 +0200 In-Reply-To: (Stefan Monnier's message of "Sun, 07 Aug 2016 22:04:15 -0400") Message-ID: <87wpjqpqqk.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:pOlIaKiwZGDGTo89NGa4lucMikJJNwmATpwPOSAw151WlgVFyiB 5nzlJSKvB3VYH0AfDV5A66Yji9zZtF0ZVX4+yiNmJMksZeSNXfh5Xn/pt/nluTRUXn/lWsO gWgnCMOkieKzcxU19mQ4OUp9Nd0b/VwIqbmzBcRAvOecZsviQb4H/FydWrnGEMC8SdAmp3i 10Vr8Zk7l6L/btBG3Pecw== X-UI-Out-Filterresults: notjunk:1;V01:K0:9HIDzoASZhY=:/u+ZqUH36Gf1E2Js4fmd6w YjdHFekP8H0XecrdT+6VJS1lco6VM2H15LG4OdMdxyH1kUe/S8+fzyZ/OqYa9b5QnrUmantCL HL4SqYjfXs0a0YrAHjKnIRajnnQa4Ge8VZ7hrZivAuLvkgMdrG04H7mEalNehswexr3kYBkFE TnfncfbrSBL3+Te/S/ZMuKzfMuPsHGNQF3OKYhRcyJdl100jagvkMBe5WSh9Y/rC3dbVRjWJ8 jG3byBVDRBSnzQXGH/mR7Ny5xMnpAtU1zH70BueWspnB9cF6RYnYBfDWinbzB9L/uOT9wmCna YhIh2qzeTJMVNnWxYJ5uyqB+l0bYpIlDhQgl5CDAfB0fywnl41Rd3P+yn1LHcBSV4B+qu3CN0 48K4IsdH4dPKGe9S1W7Xgo/j/ueAcGue1k1z9TBQFc2EIk+W5u/NZjEjE0+Qbj6nopr6BjuCV K0GOVKoxd0CLiwUtYmrrRU/QwgEGyk4uQ1VsVgf+8RvvLRrIw2rnhGljOfJSdzfjJM6mF3DEN 9y3GQmZKG4ctNvZtuNiv1rgC0zMB6EdX1aaQ48Vx4/LMM4fxxCBXObDFWtCp/NDFa5QYBtjTj 7avt7YgFR+RjRu4hVvsa80UXROoY5EF9Mp7OVJpHm2hI3KWK8RysEpZLO/FLIpHit4zPm8Ios rrvgs2/exMYP8jFPVkD2+Vj/HpAVcZ8Kdw8LzVgj0r1razVAGYBxFbh0RxwLgLcvmYmLmsSxl sUMwXa/G1JGChkWNJhSZYSAk0oGI5lDz2mgGhvfI62msS6sfWIhQpMoKq51cvrix8BhO006tO /ejvn0F X-Spam-Score: -1.2 (-) X-Debbugs-Envelope-To: 24171 Cc: 24171@debbugs.gnu.org, Alex Vong X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) Stefan Monnier writes: > IOW I intend to install it into master. master sounds good to me. But wait, what's this: (defun test () (let ((x 1)) (let ((x 2) (f (function (lambda (y) (/ y x))))) (funcall f x)))) (test) => 2 compile... (test) ==> 1 ? Thanks, Michael. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 08 23:48:25 2016 Received: (at 24171) by debbugs.gnu.org; 9 Aug 2016 03:48:25 +0000 Received: from localhost ([127.0.0.1]:60587 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWy1h-0003wX-AL for submit@debbugs.gnu.org; Mon, 08 Aug 2016 23:48:25 -0400 Received: from mout.web.de ([212.227.15.3]:50313) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bWy1a-0003wF-Km for 24171@debbugs.gnu.org; Mon, 08 Aug 2016 23:48:23 -0400 Received: from drachen.dragon ([92.216.132.91]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0MMW5u-1baoIr2eIo-008MfJ; Tue, 09 Aug 2016 05:48:07 +0200 From: Michael Heerdegen To: Stefan Monnier Subject: Re: bug#24171: 25.1; Bytecode returns nil instead of expected closure References: <877fbtqyhp.fsf@web.de> <87wpjqpqqk.fsf@web.de> Date: Tue, 09 Aug 2016 05:48:05 +0200 In-Reply-To: <87wpjqpqqk.fsf@web.de> (Michael Heerdegen's message of "Tue, 09 Aug 2016 05:26:27 +0200") Message-ID: <87tweuhabu.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:/F/C0wK2oRmVQKhzrgh8ET8REhyMb9Go6M92GM24eUgObcFTaOF FCF9GMv0PF+HOR8ysrHdL7mzQk2SGPkTugDo7f/D52gzmOIozidPTjMic3bkBqK8yjNi+oq u+pIbfFCfqGwQ28c2Or3SF4e39192Da4ZP5BDiF9lnOSgPH2QCy/D+9w/SKyx6BZHu1PQJ0 hjQhQ0QqHIll5H+197xGA== X-UI-Out-Filterresults: notjunk:1;V01:K0:DrlztALamnc=:xY5meu2gACnDHDXoPotQYm 7Oj2XVCEK384vXNxY5GRtPUbh0iuRr8TIbyiT96CnDE9W2mhDGWul167INGd7ScD1FJuP9g4/ XjBvZ0HQYsr2xddXYWI+ctGMe0K6cJZ3Vd0cFyea3BUGVwnMaO5yk+U7NWAQuDqHBu2WnFUm3 HgOKJJCd8YUWmxQfkg7dEWvVmE0Z6O3wZHKfxlHVdekgnbBi1efjkchbXeGkzK8L78NyvjG/l q2u5NHWgSI7lTLzJPKqlSYdvWkS9Bk32KO46U8/u/UeR6p2lHH5yjt+Lc7rWJWLATrMZWOVyT kAJoUS1ditw/U03EqaH8beIl3OrSJPZFzliNuQDkMSU9QhS3pSjcyiThnfRYigy8Xo/pQHCrN rawek/Z87Ug+hAgjPxKmuejDvZ14nUmaBD6IwV3ue4R379HeCUtTSuhQyEBEAH8RRb8Ch7AOo Jx8YCmKEMMLq5utj3tFN5vaHaAGWRSXQJ02CPKZs6KbbSmpKnPxH13QLnAPgshr+oBA1/98yr qUKjFpGdLL4W5U8F5mkTLsNY4PPzlqFzklgn9JK+TKu4jwC/Q7d1339QJrDwWvEkOv3mbmf8J 8I1NhHULDZqB285JwLgODkAj0zHtCrGqssQi37Zy1ZUzHpvhVuw/u8CQ02Nsapfj9DdIGmVyx /2K3IKnwQhWMYSiom8P5ibd/IVJkmjDfpxUjQo1PTsIvZmtJouNNj0z63bRjZbHWRPUeUmAqu gXVKsIWaLZD4do5QHQOgMPVEm3B6NwCJIk3JtfVhvUmVyvoGL5V8D20Qh9pJ0KeeWCwoOabJ7 sS1T4oq X-Spam-Score: -1.2 (-) X-Debbugs-Envelope-To: 24171 Cc: 24171@debbugs.gnu.org, Alex Vong X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) Michael Heerdegen writes: > (test) => 2 > > compile... > > (test) ==> 1 ? That was false alarm, everything is fine, I forgot to enable lexical-binding or whatever. Thanks for the quick fix, Michael. From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 09 13:11:44 2016 Received: (at 24171-done) by debbugs.gnu.org; 9 Aug 2016 17:11:44 +0000 Received: from localhost ([127.0.0.1]:33325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bXAZ6-0003xn-Lr for submit@debbugs.gnu.org; Tue, 09 Aug 2016 13:11:44 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:24703) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bXAZ3-0003xZ-7j for 24171-done@debbugs.gnu.org; Tue, 09 Aug 2016 13:11:43 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BIFgA731xV/37q92hcgxBUXoJQhVW7QIEtIwqFcQQCAoE8OxIBAQEBAQEBgQpBBYNdAQEBAgEBAlMjBQsLNBIUFAQNJIg3CAUIzxYBAQEBAQUCARsEizqFBQeELQEElyGEGooVjzQjhBQiMQGCRgEBAQ X-IPAS-Result: A0BIFgA731xV/37q92hcgxBUXoJQhVW7QIEtIwqFcQQCAoE8OxIBAQEBAQEBgQpBBYNdAQEBAgEBAlMjBQsLNBIUFAQNJIg3CAUIzxYBAQEBAQUCARsEizqFBQeELQEElyGEGooVjzQjhBQiMQGCRgEBAQ X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="250734476" Received: from 104-247-234-126.cpe.teksavvy.com (HELO pastel.home) ([104.247.234.126]) by smtp.teksavvy.com with ESMTP; 09 Aug 2016 13:11:33 -0400 Received: by pastel.home (Postfix, from userid 20848) id BCFC164E2A; Tue, 9 Aug 2016 13:05:31 -0400 (EDT) From: Stefan Monnier To: Alex Vong Subject: Re: bug#24171: 25.1; Bytecode returns nil instead of expected closure Message-ID: References: <877fbtqyhp.fsf@web.de> <87twevmtoi.fsf@gmail.com> Date: Tue, 09 Aug 2016 13:05:31 -0400 In-Reply-To: <87twevmtoi.fsf@gmail.com> (Alex Vong's message of "Mon, 08 Aug 2016 18:38:53 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 24171-done Cc: Michael Heerdegen , 24171-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > Yes, this fixes the original problem. > (https://lists.gnu.org/archive/html/help-gnu-emacs/2016-08/msg00038.html) > The test is performed on master branch with patch applied. Thanks, installed. Stefan From unknown Sun Aug 10 16:50:37 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 07 Sep 2016 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator