When expanding (VALUES ...) in SF, integrate the receiver.
authorTaylor R Campbell <campbell@mumble.net>
Mon, 21 Sep 2009 22:38:22 +0000 (18:38 -0400)
committerTaylor R Campbell <campbell@mumble.net>
Mon, 21 Sep 2009 22:38:22 +0000 (18:38 -0400)
src/sf/usiexp.scm

index 5d50463f2a374b3ac19f5c87209299dd062365dd..d596073e0495e773bdcb026dd682e07f1cf46f52 100644 (file)
@@ -351,7 +351,7 @@ USA.
       (make-combination expr block (ucode-primitive cons)
                        (list (car rest)
                              (list-expansion-loop #f block (cdr rest))))))
-
+\f
 (define (values-expansion expr operands if-expanded if-not-expanded block)
   if-not-expanded
   (if-expanded
@@ -373,12 +373,18 @@ USA.
           (let ((variable (variable/make&bind! block 'RECEIVER)))
             (procedure/make
              #f block lambda-tag:unnamed (list variable) '() #f
-             (combination/make #f
-                               block
-                               (reference/make #f block variable)
-                               (map (lambda (variable)
-                                      (reference/make #f block variable))
-                                    variables))))))
+             (declaration/make
+              #f
+              ;; The receiver is used only once, and all its operand
+              ;; expressions are effect-free, so integrating here is
+              ;; safe.
+              (declarations/parse block '((INTEGRATE-OPERATOR RECEIVER)))
+              (combination/make #f
+                                block
+                                (reference/make #f block variable)
+                                (map (lambda (variable)
+                                       (reference/make #f block variable))
+                                     variables)))))))
        operands)))))
 
 (define (call-with-values-expansion expr operands