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
(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
;;; 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))))
;;; 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"