From debbugs-submit-bounces@debbugs.gnu.org Thu May 29 16:36:50 2014 Received: (at submit) by debbugs.gnu.org; 29 May 2014 20:36:50 +0000 Received: from localhost ([127.0.0.1]:36486 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wq74E-000140-0I for submit@debbugs.gnu.org; Thu, 29 May 2014 16:36:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58195) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wq74B-00013e-K0 for submit@debbugs.gnu.org; Thu, 29 May 2014 16:36:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wq73w-0007Ag-Pr for submit@debbugs.gnu.org; Thu, 29 May 2014 16:36:42 -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.5 required=5.0 tests=BAYES_05 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wq73w-0007Ac-NZ for submit@debbugs.gnu.org; Thu, 29 May 2014 16:36:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wq73p-0003tM-01 for bug-guile@gnu.org; Thu, 29 May 2014 16:36:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wq73h-000768-Hg for bug-guile@gnu.org; Thu, 29 May 2014 16:36:24 -0400 Received: from primfilat.com ([71.19.154.166]:56669) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wq73h-00075N-Bx for bug-guile@gnu.org; Thu, 29 May 2014 16:36:17 -0400 Received: from x60 (unknown [46.18.46.105]) by primfilat.com (Postfix) with ESMTPSA id 93FD57B894 for ; Thu, 29 May 2014 22:36:14 +0200 (CEST) From: Josep Portella Florit To: bug-guile@gnu.org Subject: "Unbound var" compilation error, lambda* & #:optional Date: Thu, 29 May 2014 22:36:08 +0200 Message-ID: <878upk1fwn.fsf@primfilat.com> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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.15 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 (----) Hi! Please, see the attached REPL session. Regards scheme@(guile-user)> ((lambda* (a #:optional (b (+ a 1))) b) 1) While compiling expression: ERROR: unbound var a-492 scheme@(guile-user)> (define f (lambda* (a #:optional (b (+ a 1))) b)) scheme@(guile-user)> (f 1) $2 = 2 scheme@(guile-user)> ((lambda* (a #:key (b (+ a 1))) b) 1) $3 = 2 (Tested on Guile 2.0.11) From debbugs-submit-bounces@debbugs.gnu.org Fri May 30 02:18:32 2014 Received: (at 17634) by debbugs.gnu.org; 30 May 2014 06:18:33 +0000 Received: from localhost ([127.0.0.1]:36786 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WqG9A-0004Hu-0P for submit@debbugs.gnu.org; Fri, 30 May 2014 02:18:32 -0400 Received: from world.peace.net ([96.39.62.75]:56154 ident=hope9) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WqG97-0004Hl-Nw for 17634@debbugs.gnu.org; Fri, 30 May 2014 02:18:30 -0400 Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong.lan) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1WqG8z-0003BZ-Nl; Fri, 30 May 2014 02:18:21 -0400 From: Mark H Weaver To: Josep Portella Florit Subject: Re: bug#17634: "Unbound var" compilation error, lambda* & #:optional References: <878upk1fwn.fsf@primfilat.com> Date: Fri, 30 May 2014 02:18:17 -0400 In-Reply-To: <878upk1fwn.fsf@primfilat.com> (Josep Portella Florit's message of "Thu, 29 May 2014 22:36:08 +0200") Message-ID: <877g53vlg6.fsf@yeeloong.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 17634 Cc: 17634@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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.0 (/) --=-=-= Content-Type: text/plain Josep Portella Florit writes: > scheme@(guile-user)> ((lambda* (a #:optional (b (+ a 1))) b) 1) > While compiling expression: > ERROR: unbound var a-492 > scheme@(guile-user)> (define f (lambda* (a #:optional (b (+ a 1))) b)) > scheme@(guile-user)> (f 1) > $2 = 2 > scheme@(guile-user)> ((lambda* (a #:key (b (+ a 1))) b) 1) > $3 = 2 > > (Tested on Guile 2.0.11) The following preliminary patch should fix the problem. I haven't yet pushed it because I'd like to add some test cases, and have Andy or Ludovic review the patch. Thanks! Mark --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-peval-Handle-optional-argument-inits-that-refer-to-p.patch Content-Description: [PATCH] peval: Handle optional argument inits that refer to previous arguments >From 4d8002afa0ab851d9878c56c538dd2c8cbd7fc93 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Fri, 30 May 2014 01:27:08 -0400 Subject: [PATCH] peval: Handle optional argument inits that refer to previous arguments. Fixes . Reported by Josep Portella Florit . * module/language/tree-il/peval.scm (inlined-application): When inlining an application whose operator is a lambda expression with optional arguments that rely on default initializers, expand into a series of nested let expressions, to ensure that previous arguments are in scope when the default initializers are evaluated. --- module/language/tree-il/peval.scm | 51 +++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/module/language/tree-il/peval.scm b/module/language/tree-il/peval.scm index bd92edc..04563d6 100644 --- a/module/language/tree-il/peval.scm +++ b/module/language/tree-il/peval.scm @@ -1313,24 +1313,49 @@ top-level bindings from ENV and return the resulting expression." (nopt (if opt (length opt) 0)) (key (source-expression proc))) (define (inlined-application) - (make-let src - (append req - (or opt '()) - (if rest (list rest) '())) - gensyms - (if (> nargs (+ nreq nopt)) - (append (list-head orig-args (+ nreq nopt)) + (if (> nargs (+ nreq nopt)) + (make-let src + (append req + (or opt '()) + (list rest)) + gensyms + (append (take orig-args (+ nreq nopt)) (list (make-application #f (make-primitive-ref #f 'list) (drop orig-args (+ nreq nopt))))) - (append orig-args - (drop inits (- nargs nreq)) - (if rest - (list (make-const #f '())) - '()))) - body)) + body) + (let*-values + (((non-rest-gensyms rest-gensyms) + (split-at gensyms (+ nreq nopt))) + ((provided-gensyms default-gensyms) + (split-at non-rest-gensyms nargs)) + ((provided-vars default-vars) + (split-at (append req (or opt '())) + nargs)) + ((rest-vars) + (if rest (list rest) '())) + ((rest-inits) + (if rest + (list (make-const #f '())) + '())) + ((default-inits) + (drop inits (- nargs nreq)))) + (make-let src + (append provided-vars rest-vars) + (append provided-gensyms rest-gensyms) + (append orig-args rest-inits) + (fold-right (lambda (var gensym init body) + (make-let src + (list var) + (list gensym) + (list init) + body)) + body + default-vars + default-gensyms + default-inits))))) (cond ((or (< nargs nreq) (and (not rest) (> nargs (+ nreq nopt)))) -- 1.8.4 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 29 00:02:26 2014 Received: (at 17634-done) by debbugs.gnu.org; 29 Sep 2014 04:02:26 +0000 Received: from localhost ([127.0.0.1]:54742 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XYSAL-0007s1-Oc for submit@debbugs.gnu.org; Mon, 29 Sep 2014 00:02:25 -0400 Received: from world.peace.net ([96.39.62.75]:60307) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XYSAJ-0007rt-NH for 17634-done@debbugs.gnu.org; Mon, 29 Sep 2014 00:02:24 -0400 Received: from c-24-62-95-23.hsd1.ma.comcast.net ([24.62.95.23] helo=yeeloong.lan) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1XYSAD-0007Xy-3P; Mon, 29 Sep 2014 00:02:17 -0400 From: Mark H Weaver To: Josep Portella Florit Subject: Re: bug#17634: "Unbound var" compilation error, lambda* & #:optional References: <878upk1fwn.fsf@primfilat.com> Date: Mon, 29 Sep 2014 00:02:09 -0400 In-Reply-To: <878upk1fwn.fsf@primfilat.com> (Josep Portella Florit's message of "Thu, 29 May 2014 22:36:08 +0200") Message-ID: <87eguvaxby.fsf@yeeloong.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 17634-done Cc: 17634-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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.0 (/) Josep Portella Florit writes: > scheme@(guile-user)> ((lambda* (a #:optional (b (+ a 1))) b) 1) > While compiling expression: > ERROR: unbound var a-492 > scheme@(guile-user)> (define f (lambda* (a #:optional (b (+ a 1))) b)) > scheme@(guile-user)> (f 1) > $2 = 2 > scheme@(guile-user)> ((lambda* (a #:key (b (+ a 1))) b) 1) > $3 = 2 Fixed in 7a71a45cfd6092402d540e9bc5d2432941a8a336 on the stable-2.0 branch. I'm closing this bug. Thanks! Mark From unknown Thu Aug 21 14:53:57 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 27 Oct 2014 11:24:04 +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