aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2017-03-11 18:20:22 -0400
committerEduardo Julian2017-03-11 18:20:22 -0400
commita902bbaaceccb11316c6804c459181f62ce7e6a9 (patch)
tree23e6687ec595a10da8483d8d8d67c756be8f3e81
parent2bd7d936e0ca47e445c7d946aa1ae8287a62f049 (diff)
- Now resetting the mappings of the type-vars to avoid having undead type-vars interfering with compilation.
-rw-r--r--luxc/src/lux/analyser/lux.clj8
-rw-r--r--luxc/src/lux/type.clj14
2 files changed, 18 insertions, 4 deletions
diff --git a/luxc/src/lux/analyser/lux.clj b/luxc/src/lux/analyser/lux.clj
index aee46a9cc..304705331 100644
--- a/luxc/src/lux/analyser/lux.clj
+++ b/luxc/src/lux/analyser/lux.clj
@@ -559,7 +559,13 @@
==meta (eval! (optimize =meta))
_ (&&module/test-type module-name ?name ==meta (&&/expr-type* =value))
_ (&&module/test-macro module-name ?name ==meta (&&/expr-type* =value))
- _ (compile-def ?name (optimize =value) ==meta)]
+ _ (compile-def ?name (optimize =value) ==meta)
+ ;; TODO: Make the call to &type/reset-mappings unnecessary.
+ ;; It shouldn't be necessary to reset the mappings of the
+ ;; type-vars, because those mappings shouldn't stay around
+ ;; after being cleaned-up.
+ ;; I must figure out why they're staying around.
+ _ &type/reset-mappings]
(return &/$Nil))
)))
diff --git a/luxc/src/lux/type.clj b/luxc/src/lux/type.clj
index a0729f040..dd2e536bb 100644
--- a/luxc/src/lux/type.clj
+++ b/luxc/src/lux/type.clj
@@ -215,7 +215,7 @@
(&/$None)
(return* (&/update$ &/$type-vars (fn [ts] (&/update$ &/$mappings #(&/|put id (&/$Some type) %)
- ts))
+ ts))
state)
nil))
((&/fail-with-loc (str "[Type Error] <set-var> Unknown type-var: " id " | " (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length)))
@@ -225,7 +225,7 @@
(fn [state]
(if-let [tvar (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) (&/|get id))]
(return* (&/update$ &/$type-vars (fn [ts] (&/update$ &/$mappings #(&/|put id (&/$Some type) %)
- ts))
+ ts))
state)
nil)
((&/fail-with-loc (str "[Type Error] <set-var> Unknown type-var: " id " | " (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length)))
@@ -235,7 +235,7 @@
(fn [state]
(if-let [tvar (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) (&/|get id))]
(return* (&/update$ &/$type-vars (fn [ts] (&/update$ &/$mappings #(&/|put id &/$None %)
- ts))
+ ts))
state)
nil)
((&/fail-with-loc (str "[Type Error] <set-var> Unknown type-var: " id " | " (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length)))
@@ -243,6 +243,14 @@
;; [Exports]
;; Type vars
+(def reset-mappings
+ (fn [state]
+ (return* (&/update$ &/$type-vars #(->> %
+ ;; (&/set$ &/$counter 0)
+ (&/set$ &/$mappings (&/|table)))
+ state)
+ nil)))
+
(def create-var
(fn [state]
(let [id (->> state (&/get$ &/$type-vars) (&/get$ &/$counter))]