From 3743b7fdd39597b5a1b601014fe2e7f50a46100f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 7 May 2019 22:48:26 -0400 Subject: Fixed a bug when analyzing type-coercions. --- .../compiler/phase/extension/analysis/common.lux | 52 +++++++++++++--------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'stdlib/source') 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 [ ] - [(def: ( 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 - (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) -- cgit v1.2.3