GNU bug report logs -
#38263
Bug in srfi-11 (?)
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Hi Tim,
> Mark H Weaver writes:
>> I agree that this example indicates a bug in Guile's 'let-values'
>> implementation (which was written by Andy Wingo in August 2009), but I
>> disagree that it should evaluate to '(9 2 (3) (4)). I think that your
>> example should raise an error, because at the point where (set! a 9) is
>> found, neither of the 'a' variables are in scope.
>
> Oops, that `let` should have been a `let*` (Moving the first a into
> scope). But if you could verify that what I described is a bug I would
> like to propose a patch.
I agree that it's a bug, and that if you change 'let' to 'let*' in your
previous example, the result should be '(9 2 (3) (4)).
I took a quick look, and I believe the fix is simply to swap 'new-var'
and 'new-tmp' on line 95 of srfi-11.scm. See the attached patch. Does
it fix the problems you're seeing?
Thanks,
Mark
[0001-Fix-let-values-where-formals-is-an-improper-list.patch (text/x-patch, inline)]
From 4657b95713facffcde685b578ed19dbeb45624d0 Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw <at> netris.org>
Date: Sun, 24 Nov 2019 14:46:45 -0500
Subject: [PATCH] Fix 'let-values' where <formals> is an improper list.
Fixes <https://bugs.gnu.org/38263>.
Reported by Tim Gesthuizen <tim.gesthuizen <at> yahoo.de>.
* module/srfi/srfi-11.scm (let-values): Swap 'new-tmp' and 'new-var' in
the pair pattern, to match the code that creates those pairs.
---
module/srfi/srfi-11.scm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/module/srfi/srfi-11.scm b/module/srfi/srfi-11.scm
index 22bda21a2..42b8527ba 100644
--- a/module/srfi/srfi-11.scm
+++ b/module/srfi/srfi-11.scm
@@ -1,6 +1,7 @@
;;; srfi-11.scm --- let-values and let*-values
-;; Copyright (C) 2000, 2001, 2002, 2004, 2006, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2002, 2004, 2006, 2009,
+;; 2019 Free Software Foundation, Inc.
;;
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
@@ -91,7 +92,7 @@
(syntax (call-with-values (lambda () exp)
(lambda (new-tmp ...) inner))))))
((vars exp)
- (with-syntax ((((new-tmp . new-var) ...)
+ (with-syntax ((((new-var . new-tmp) ...)
(let lp ((vars (syntax vars)))
(syntax-case vars ()
((id . rest)
--
2.24.0
This bug report was last modified 5 years and 133 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.