0.7.9.25:
authorAlexey Dejneka <adejneka@comail.ru>
Fri, 1 Nov 2002 17:31:49 +0000 (17:31 +0000)
committerAlexey Dejneka <adejneka@comail.ru>
Fri, 1 Nov 2002 17:31:49 +0000 (17:31 +0000)
        Fixed PROGV with different number of variables and values
        (bug from Paul Dietz' test suit)

NEWS
src/compiler/ir2tran.lisp
tests/compiler.pure-cload.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index f5f7b3c..739f51d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1363,6 +1363,8 @@ changes in sbcl-0.7.10 relative to sbcl-0.7.9:
         correct order
      ** MULTIPLE-VALUE-SETQ evaluates side-effectful places before
         value producing form
+     ** if more variables are given to PROGV than values, extra
+        variables are bound and made to have no value
    * fixed bug 166: compiler preserves "there is a way to go"
      invariant when deleting code
 
index d32325b..b916025 100644 (file)
 (def-ir1-translator progv ((vars vals &body body) start cont)
   (ir1-convert
    start cont
-   (once-only ((n-save-bs '(%primitive current-binding-pointer)))
-     `(unwind-protect
-         (progn
-           (mapc (lambda (var val)
-                   (%primitive bind val var))
-                 ,vars
-                 ,vals)
-           ,@body)
-       (%primitive unbind-to-here ,n-save-bs)))))
+   (let ((bind (gensym "BIND"))
+         (unbind (gensym "UNBIND")))
+     (once-only ((n-save-bs '(%primitive current-binding-pointer)))
+                `(unwind-protect
+                      (progn
+                        (labels ((,unbind (vars)
+                                   (declare (optimize (speed 2) (debug 0)))
+                                   (dolist (var vars)
+                                     (%primitive bind nil var)
+                                     (makunbound var)))
+                                 (,bind (vars vals)
+                                   (declare (optimize (speed 2) (debug 0)))
+                                   (cond ((null vars))
+                                         ((null vals) (,unbind vars))
+                                         (t (%primitive bind (car vals) (car vars))
+                                            (,bind (cdr vars) (cdr vals))))))
+                          (,bind ,vars ,vals))
+                        nil
+                        ,@body)
+                   (%primitive unbind-to-here ,n-save-bs))))))
 \f
 ;;;; non-local exit
 
index c1b5ef1..3f913cf 100644 (file)
 ;;; This is a slightly different way of getting the same symptoms out
 ;;; of the sbcl-0.6.11.13 byte compiler bug.
 (print (setq *print-level* *print-level*))
+
+;;; PROGV with different numbers of variables and values
+(let ((a 1))
+  (declare (special a))
+  (assert (equal (list a (progv '(a b) '(:a :b :c)
+                           (assert (eq (symbol-value 'nil) nil))
+                           (list (symbol-value 'a) (symbol-value 'b)))
+                       a)
+                 '(1 (:a :b) 1)))
+  (assert (equal (list a (progv '(a b) '(:a :b)
+                           (assert (eq (symbol-value 'nil) nil))
+                           (list (symbol-value 'a) (symbol-value 'b)))
+                       a)
+                 '(1 (:a :b) 1)))
+  (assert (not (boundp 'b))))
+
+(let ((a 1) (b 2))
+  (declare (special a b))
+  (assert (equal (list a b (progv '(a b) '(:a)
+                             (assert (eq (symbol-value 'nil) nil))
+                             (assert (not (boundp 'b)))
+                             (symbol-value 'a))
+                       a b)
+                 '(1 2 :a 1 2))))
index b5cf244..02ea309 100644 (file)
@@ -18,4 +18,4 @@
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
 
-"0.7.9.24"
+"0.7.9.25"