Skip to content

Instantly share code, notes, and snippets.

@tobias
Created November 22, 2013 04:52
Show Gist options
  • Select an option

  • Save tobias/7595028 to your computer and use it in GitHub Desktop.

Select an option

Save tobias/7595028 to your computer and use it in GitHub Desktop.
Changes:
Modified src/jvm/clojure/lang/Var.java
diff --git a/src/jvm/clojure/lang/Var.java b/src/jvm/clojure/lang/Var.java
index 7463337..2dee064 100644
--- a/src/jvm/clojure/lang/Var.java
+++ b/src/jvm/clojure/lang/Var.java
@@ -63,8 +63,8 @@ static class Frame{
}
protected Object clone() {
- Frame f = new Frame();
- f.bindings = this.bindings;
+ Frame f = new Frame(this.bindings, null);
+ f.prev = f;
return f;
}
Modified test/clojure/test_clojure/parallel.clj
diff --git a/test/clojure/test_clojure/parallel.clj b/test/clojure/test_clojure/parallel.clj
index fb98d60..357e961 100644
--- a/test/clojure/test_clojure/parallel.clj
+++ b/test/clojure/test_clojure/parallel.clj
@@ -27,3 +27,14 @@
;; regression fixed in r1218; was OutOfMemoryError
(is (= '(1) (pmap inc [0]))))
+
+(def ^:dynamic *test-value* 1)
+
+(deftest future-fn-properly-retains-conveyed-bindings
+ (let [a (atom [])]
+ (binding [*test-value* 2]
+ @(future (dotimes [_ 3]
+ ;; we need some binding to trigger binding pop
+ (binding [*print-dup* false]
+ (swap! a conj *test-value*))))
+ (is (= [2 2 2] @a)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment