diff options
author | Tim Gesthuizen <tim.gesthuizen@yahoo.de> | 2019-12-03 18:50:37 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2020-01-12 22:18:41 +0100 |
commit | 1733efe236092f2e1a738bfd98029b6c9e4035cf (patch) | |
tree | 1101026e883a95fceec910c42bc02ca011896a00 | |
parent | 7726ed7423427043b7cd85715129a91333221635 (diff) | |
download | guile-1733efe236092f2e1a738bfd98029b6c9e4035cf.tar.gz |
srfi-11: Do not expose variables to later clauses
The current implementation of srfi-11s let-values allows later clauses
to access and modify variables bound in earlier clauses when the clause
is not a proper list.
* module/srfi/srfi-11.scm (let-values): Fix switched variable names.
* test-suite/tests/srfi-11.test (let-values): Add test checking that the
variable cannot be changed in later clauses.
-rw-r--r-- | module/srfi/srfi-11.scm | 2 | ||||
-rw-r--r-- | test-suite/tests/srfi-11.test | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/module/srfi/srfi-11.scm b/module/srfi/srfi-11.scm index 22bda21a2..7afac9c5f 100644 --- a/module/srfi/srfi-11.scm +++ b/module/srfi/srfi-11.scm @@ -91,7 +91,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) diff --git a/test-suite/tests/srfi-11.test b/test-suite/tests/srfi-11.test index 40563dc18..9bfaa4300 100644 --- a/test-suite/tests/srfi-11.test +++ b/test-suite/tests/srfi-11.test @@ -74,7 +74,14 @@ '(unbound-variable . ".*") (let-values (((x) (values 1)) ((y) (values (1+ x)))) - #f)))) + #f)) + + (pass-if "first binding with rest invisible to second expr" + (let* ((a 1) + (b (let-values (((a . b) (values 2 3)) + (c (begin (set! a 9) 4))) + (list a b c)))) + (equal? (cons a b) '(9 2 (3) (4))))))) ;; ;; let*-values |