From 75543cbbc31313701087ed10d1a99e5a1eaedb74 Mon Sep 17 00:00:00 2001
From: Eduardo Julian
Date: Fri, 28 Oct 2016 19:40:21 -0400
Subject: - Fixed the bug that caused trouble between caching and parallel
 compilation.

---
 src/lux/compiler/cache.clj | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

(limited to 'src')

diff --git a/src/lux/compiler/cache.clj b/src/lux/compiler/cache.clj
index 4f90c7cce..374993a7a 100644
--- a/src/lux/compiler/cache.clj
+++ b/src/lux/compiler/cache.clj
@@ -76,6 +76,17 @@
           bytecode (read-file file)]
       (swap! !classes assoc (str module* "." real-name) bytecode))))
 
+(defn ^:private assume-async-result
+  "(-> (Error Compiler) (Lux Null))"
+  [result]
+  (fn [_]
+    (|case result
+      (&/$Left error)
+      (&/$Left error)
+
+      (&/$Right compiler)
+      (return* compiler nil))))
+
 (let [->regex (fn [text] (re-pattern (java.util.regex.Pattern/quote text)))
       entry-separator-re (->regex &&/entry-separator)
       field-separator-re (->regex &&/field-separator)
@@ -88,8 +99,9 @@
     (|do [already-loaded? (&a-module/exists? module)]
       (if already-loaded?
         (return module-hash)
-        (|let [redo-cache (|do [_ (delete module)]
-                            (compile-module module))]
+        (|let [redo-cache (|do [_ (delete module)
+                                async (compile-module module)]
+                            (assume-async-result @async))]
           (if (cached? module)
             (|do [loader &/loader
                   !classes &/classes
-- 
cgit v1.2.3