aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2019-05-07 22:48:26 -0400
committerEduardo Julian2019-05-07 22:48:26 -0400
commit3743b7fdd39597b5a1b601014fe2e7f50a46100f (patch)
tree9f8c0b85f3b31281aa2b4dacddfd086f49fdf9bb /stdlib/source
parent4a81610a54b43b2084976ee4ebc86b3b94fb047c (diff)
Fixed a bug when analyzing type-coercions.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux52
1 files changed, 32 insertions, 20 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux b/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux
index c315f8d9d..e6a58e3b7 100644
--- a/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux
+++ b/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux
@@ -94,26 +94,38 @@
_
(/////analysis.throw ///.invalid-syntax [extension-name %code argsC+]))))
-(template [<name> <type>]
- [(def: (<name> eval)
- (-> Eval Handler)
- (function (_ extension-name analyse args)
- (case args
- (^ (list typeC valueC))
- (do ////.monad
- [count (///.lift macro.count)
- actualT (:: @ map (|>> (:coerce Type))
- (eval count Type typeC))
- _ (typeA.infer actualT)]
- (typeA.with-type <type>
- (analyse valueC)))
-
- _
- (/////analysis.throw ///.incorrect-arity [extension-name 2 (list.size args)]))))]
-
- [lux::check actualT]
- [lux::coerce Any]
- )
+(def: (lux::check eval)
+ (-> Eval Handler)
+ (function (_ extension-name analyse args)
+ (case args
+ (^ (list typeC valueC))
+ (do ////.monad
+ [count (///.lift macro.count)
+ actualT (:: @ map (|>> (:coerce Type))
+ (eval count Type typeC))
+ _ (typeA.infer actualT)]
+ (typeA.with-type actualT
+ (analyse valueC)))
+
+ _
+ (/////analysis.throw ///.incorrect-arity [extension-name 2 (list.size args)]))))
+
+(def: (lux::coerce eval)
+ (-> Eval Handler)
+ (function (_ extension-name analyse args)
+ (case args
+ (^ (list typeC valueC))
+ (do ////.monad
+ [count (///.lift macro.count)
+ actualT (:: @ map (|>> (:coerce Type))
+ (eval count Type typeC))
+ _ (typeA.infer actualT)
+ [valueT valueA] (typeA.with-inference
+ (analyse valueC))]
+ (wrap valueA))
+
+ _
+ (/////analysis.throw ///.incorrect-arity [extension-name 2 (list.size args)]))))
(def: (caster input output)
(-> Type Type Handler)