From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#6376: 23.2; byte compile add-to-list report free variable Date: Tue, 08 Jun 2010 21:29:20 -0400 Message-ID: References: <87y6eqia4d.fsf@blah.blah> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1276048701 22143 80.91.229.12 (9 Jun 2010 01:58:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 9 Jun 2010 01:58:21 +0000 (UTC) Cc: 6376@debbugs.gnu.org To: Kevin Ryde Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 09 03:58:19 2010 connect(): No such file or directory Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OMAYb-0001qY-Ri for geb-bug-gnu-emacs@m.gmane.org; Wed, 09 Jun 2010 03:58:18 +0200 Original-Received: from localhost ([127.0.0.1]:60072 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMAYb-0007Q3-4I for geb-bug-gnu-emacs@m.gmane.org; Tue, 08 Jun 2010 21:58:17 -0400 Original-Received: from [140.186.70.92] (port=52652 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMAYV-0007Pl-77 for bug-gnu-emacs@gnu.org; Tue, 08 Jun 2010 21:58:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OMAYT-0003Hs-Ot for bug-gnu-emacs@gnu.org; Tue, 08 Jun 2010 21:58:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54544) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OMAYT-0003Hn-NO for bug-gnu-emacs@gnu.org; Tue, 08 Jun 2010 21:58:09 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OMA7I-0001hM-0V; Tue, 08 Jun 2010 21:30:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Jun 2010 01:30:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6376 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 6376-submit@debbugs.gnu.org id=B6376.12760469666487 (code B ref 6376); Wed, 09 Jun 2010 01:30:03 +0000 Original-Received: (at 6376) by debbugs.gnu.org; 9 Jun 2010 01:29:26 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OMA6g-0001ga-6Q for submit@debbugs.gnu.org; Tue, 08 Jun 2010 21:29:26 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OMA6f-0001gV-6O for 6376@debbugs.gnu.org; Tue, 08 Jun 2010 21:29:25 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAMOKDkxFxIwr/2dsb2JhbACeQ3K/b4UWBIxs X-IronPort-AV: E=Sophos;i="4.53,387,1272859200"; d="scan'208";a="67640100" Original-Received: from 69-196-140-43.dsl.teksavvy.com (HELO pastel.home) ([69.196.140.43]) by ironport2-out.pppoe.ca with ESMTP; 08 Jun 2010 21:29:21 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id EF2598175; Tue, 8 Jun 2010 21:29:20 -0400 (EDT) In-Reply-To: <87y6eqia4d.fsf@blah.blah> (Kevin Ryde's message of "Tue, 08 Jun 2010 11:30:42 +1000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 08 Jun 2010 21:30:04 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:37619 Archived-At: > I made a mistake with a variable name to add-to-list and wondered if the > byte compiler might report > (add-to-list 'nosuchvariable ...) > as a free variable, similar to the report for I use the code below for add-hook: (byte-defop-compiler-1 remove-hook byte-compile-add-hook) (defun byte-compile-add-hook (form) (let ((sym (car-safe (cdr-safe form)))) (when (and (eq 'quote (car-safe sym)) (setq sym (car-safe (cdr sym))) (symbolp sym)) ;; Gross hack: We want to do the sanity checks just as we would for ;; a setq so we first do a setq and then pop the byte-code that was ;; just pushed by byte-compile-variable-ref. (let ((byte-compile-output byte-compile-output) (byte-compile-maxdepth byte-compile-maxdepth) (byte-compile-depth byte-compile-depth)) (byte-compile-variable-ref 'byte-varset sym))) (byte-compile-normal-call form))) so I'm in favor of such a change, but it would need to be cleaned up such that your byte-compile-check-assign is also used for byte-compile-variable-ref (i.e. the code should be hoisted out of byte-compile-variable-ref). Also, note that add-to-list is not only a "varset" but also a "varref" (it reads the var before assigning to it). Stefan