From a902bbaaceccb11316c6804c459181f62ce7e6a9 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 11 Mar 2017 18:20:22 -0400 Subject: - Now resetting the mappings of the type-vars to avoid having undead type-vars interfering with compilation. --- luxc/src/lux/analyser/lux.clj | 8 +++++++- luxc/src/lux/type.clj | 14 +++++++++++--- 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] 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] 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] 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))] -- cgit v1.2.3