aboutsummaryrefslogtreecommitdiff
path: root/luxc/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-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))]