diff options
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/function.lux | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/new-luxc/source/luxc/lang/analysis/function.lux b/new-luxc/source/luxc/lang/analysis/function.lux index a502a9d19..eaddfa5bb 100644 --- a/new-luxc/source/luxc/lang/analysis/function.lux +++ b/new-luxc/source/luxc/lang/analysis/function.lux @@ -17,9 +17,14 @@ ["&." inference]) [".L" variable #+ Variable]))) -(exception: #export Cannot-Analyse-Function) -(exception: #export Invalid-Function-Type) -(exception: #export Cannot-Apply-Function) +(do-template [<name>] + [(exception: #export (<name> {message Text}) + message)] + + [Cannot-Analyse-Function] + [Invalid-Function-Type] + [Cannot-Apply-Function] + ) ## [Analysers] (def: #export (analyse-function analyse func-name arg-name body) @@ -28,10 +33,12 @@ [functionT macro.expected-type] (loop [expectedT functionT] (&.with-stacked-errors - (function [_] (Cannot-Analyse-Function (format " Type: " (%type expectedT) "\n" - "Function: " func-name "\n" - "Argument: " arg-name "\n" - " Body: " (%code body)))) + (function (_ _) + (ex.construct Cannot-Analyse-Function + (format " Type: " (%type expectedT) "\n" + "Function: " func-name "\n" + "Argument: " arg-name "\n" + " Body: " (%code body)))) (case expectedT (#.Named name unnamedT) (recur unnamedT) @@ -73,7 +80,7 @@ )) (#.Function inputT outputT) - (<| (:: @ map (function [[scope bodyA]] + (<| (:: @ map (function (_ [scope bodyA]) (` ("lux function" [(~+ (list/map code.int (variableL.environment scope)))] (~ bodyA))))) &.with-scope @@ -91,13 +98,14 @@ (def: #export (analyse-apply analyse funcT funcA args) (-> &.Analyser Type Analysis (List Code) (Meta Analysis)) (&.with-stacked-errors - (function [_] - (Cannot-Apply-Function (format " Function: " (%type funcT) "\n" - "Arguments:" (|> args - list.enumerate - (list/map (function [[idx argC]] - (format "\n " (%n idx) " " (%code argC)))) - (text.join-with ""))))) + (function (_ _) + (ex.construct Cannot-Apply-Function + (format " Function: " (%type funcT) "\n" + "Arguments:" (|> args + list.enumerate + (list/map (function (_ [idx argC]) + (format "\n " (%n idx) " " (%code argC)))) + (text.join-with ""))))) (do macro.Monad<Meta> [[applyT argsA] (&inference.general analyse funcT args)] (wrap (la.apply argsA funcA))))) |