summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--guix/store.scm7
-rw-r--r--tests/store.scm9
2 files changed, 13 insertions, 3 deletions
diff --git a/guix/store.scm b/guix/store.scm
index 683e125b20..495dc1692c 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -628,9 +628,10 @@ connection.  Use with care."
     (define (thunk)
       (parameterize ((current-store-protocol-version
                       (store-connection-version store)))
-        (let ((result (proc store)))
-          (close-connection store)
-          result)))
+        (call-with-values (lambda () (proc store))
+          (lambda results
+            (close-connection store)
+            (apply values results)))))
 
     (cond-expand
       (guile-3
diff --git a/tests/store.scm b/tests/store.scm
index ee3e01f33b..e168d3dcf6 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -141,6 +141,15 @@
                     (string-append (%store-prefix) "/"
                                    (make-string 32 #\e) "-foobar"))))
 
+(test-equal "with-store, multiple values"        ;<https://bugs.gnu.org/42912>
+  '(1 2 3)
+  (call-with-values
+      (lambda ()
+        (with-store s
+          (add-text-to-store s "foo" "bar")
+          (values 1 2 3)))
+    list))
+
 (test-assert "valid-path? error"
   (with-store s
     (guard (c ((store-protocol-error? c) #t))