From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.devel Subject: Re: false warnings when compiling with lexical-binding and cl-lib. Date: Sat, 23 Nov 2013 17:24:10 +0100 Organization: Emacs Helm Message-ID: <878uwfulw5.fsf@gmail.com> References: <8761rl6ael.fsf@gmail.com> <87ob5bzlvr.fsf@gmail.com> <87d2lrunbg.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1385223877 15073 80.91.229.3 (23 Nov 2013 16:24:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 Nov 2013 16:24:37 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 23 17:24:40 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VkG0e-0002Lz-8L for ged-emacs-devel@m.gmane.org; Sat, 23 Nov 2013 17:24:40 +0100 Original-Received: from localhost ([::1]:44260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VkG0d-0001Qd-Rl for ged-emacs-devel@m.gmane.org; Sat, 23 Nov 2013 11:24:39 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VkG0U-0001ID-6J for emacs-devel@gnu.org; Sat, 23 Nov 2013 11:24:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VkG0O-0005T1-Bc for emacs-devel@gnu.org; Sat, 23 Nov 2013 11:24:30 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:60938) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VkG0O-0005Ss-4X for emacs-devel@gnu.org; Sat, 23 Nov 2013 11:24:24 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VkG0M-0002Dc-3B for emacs-devel@gnu.org; Sat, 23 Nov 2013 17:24:22 +0100 Original-Received: from lbe83-2-78-243-104-167.fbx.proxad.net ([78.243.104.167]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 23 Nov 2013 17:24:22 +0100 Original-Received: from thierry.volpiatto by lbe83-2-78-243-104-167.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 23 Nov 2013 17:24:22 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 54 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: lbe83-2-78-243-104-167.fbx.proxad.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:mPHk0Vyfz3X5SQMq0Plzk7/Qe5I= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:165625 Archived-At: Thierry Volpiatto writes: > Stefan Monnier writes: > >>> This patch avoid adding a new binding by the 'into' clause when the >>> binding have been already added by a 'with' clause. >>> I wonder if this is correct, real common-lisp return an error in such >>> case, WDYT? >> >> Oh, wait, then the warning is OK. It indicates that the `with lst' is >> extraneous and unused. IOW, there's no bug to fix. We could change >> cl-loop to signal an error, but it doesn't seem to be worth the trouble. > > Yes, maybe the error message can be a little more explicit, common-lisp send a > message like this: > > ,---- > | Variable LST in INTO clause is a duplicate > | current LOOP context: COLLECT I INTO LST FINALLY. > | [Condition of type SB-INT:COMPILED-PROGRAM-ERROR] > `---- > > Also the warning is only at compile time, should we return an error on > evaluation ? > This can be detected and handled from the same function > i.e (cl--loop-handle-accum) --8<---------------cut here---------------start------------->8--- diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2209297..3faf23b 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -1564,9 +1564,13 @@ If BODY is `setq', then use SPECS for assignments rather than for bindings." (defun cl--loop-handle-accum (def &optional func) ; uses loop-* (if (eq (car cl--loop-args) 'into) - (let ((var (cl--pop2 cl--loop-args))) + (let* ((var (cl--pop2 cl--loop-args)) + (binding (list (list var def)))) (or (memq var cl--loop-accum-vars) - (progn (push (list (list var def)) cl--loop-bindings) + (cl-assert (not (member binding cl--loop-bindings)) + nil "Variable %s in INTO clause is a duplicate" + (upcase (symbol-name (caar binding)))) + (progn (push binding cl--loop-bindings) (push var cl--loop-accum-vars))) var) (or cl--loop-accum-var --8<---------------cut here---------------end--------------->8--- -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997