diff options
author | Eduardo Julian | 2017-11-13 20:02:18 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-13 20:02:18 -0400 |
commit | 2a3946e713821880ecc47580e754315349f2fe73 (patch) | |
tree | 7c32a522dff9d09293a5265baa968bc04137c944 /new-luxc/source/luxc/lang/analysis/common.lux | |
parent | ca297162d5416a8c7b8af5f27757900d82d3ad03 (diff) |
- Type-vars no longer get deleted.
- Fixed some bugs.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/common.lux | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/new-luxc/source/luxc/lang/analysis/common.lux b/new-luxc/source/luxc/lang/analysis/common.lux index 4cbf5aedf..4d16e4ae6 100644 --- a/new-luxc/source/luxc/lang/analysis/common.lux +++ b/new-luxc/source/luxc/lang/analysis/common.lux @@ -1,7 +1,7 @@ (;module: lux (lux (control monad - pipe) + ["ex" exception #+ exception:]) (data text/format [product]) [meta #+ Monad<Meta>] @@ -14,28 +14,25 @@ (All [a] (-> (Meta Analysis) (Meta [Type Analysis]))) (do Monad<Meta> [[var-id var-type] (&;with-type-env - tc;create) + tc;var) analysis (&;with-expected-type var-type action) analysis-type (&;with-type-env - (tc;clean var-id var-type)) - _ (&;with-type-env - (tc;delete var-id))] + (tc;clean var-id var-type))] (wrap [analysis-type analysis]))) (def: #export (with-var body) (All [a] (-> (-> [Nat Type] (Meta a)) (Meta a))) (do Monad<Meta> [[id var] (&;with-type-env - tc;create) - output (body [id var]) - _ (&;with-type-env - (tc;delete id))] - (wrap output))) + tc;var)] + (body [id var]))) + +(exception: #export Variant-Tag-Out-Of-Bounds) (def: #export (variant-out-of-bounds-error type size tag) (All [a] (-> Type Nat Nat (Meta a))) - (&;fail (format "Trying to create variant with tag beyond type's limitations." "\n" - " Tag: " (%i (nat-to-int tag)) "\n" - "Size: " (%i (nat-to-int size)) "\n" - "Type: " (%type type)))) + (&;throw Variant-Tag-Out-Of-Bounds + (format " Tag: " (%n tag) "\n" + "Variant Size: " (%n size) "\n" + "Variant Type: " (%type type)))) |