aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/analyser
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/analyser.lux21
-rw-r--r--new-luxc/source/luxc/analyser/structure.lux24
2 files changed, 27 insertions, 18 deletions
diff --git a/new-luxc/source/luxc/analyser.lux b/new-luxc/source/luxc/analyser.lux
index 97312b805..b10f29369 100644
--- a/new-luxc/source/luxc/analyser.lux
+++ b/new-luxc/source/luxc/analyser.lux
@@ -67,28 +67,28 @@
(#;Symbol reference)
(&&reference;analyse-reference reference)
- (^ (#;Form (list [_ (#;Symbol ["" "_lux_function"])]
+ (^ (#;Form (list [_ (#;Text "lux function")]
[_ (#;Symbol ["" func-name])]
[_ (#;Symbol ["" arg-name])]
body)))
(&&function;analyse-function analyse func-name arg-name body)
- (^template [<proc> <analyser>]
- (^ (#;Form (list [_ (#;Symbol ["" <proc>])] type value)))
+ (^template [<special> <analyser>]
+ (^ (#;Form (list [_ (#;Text <special>)] type value)))
(<analyser> analyse eval type value))
- (["_lux_check" &&type;analyse-check]
- ["_lux_coerce" &&type;analyse-coerce])
+ (["lux check" &&type;analyse-check]
+ ["lux coerce" &&type;analyse-coerce])
- (^ (#;Form (list& [_ (#;Text proc-name)] proc-args)))
- (&&procedure;analyse-procedure analyse proc-name proc-args)
-
- (^ (#;Form (list& [_ (#;Symbol ["" "_lux_case"])]
+ (^ (#;Form (list& [_ (#;Text "lux case")]
input
branches)))
(do meta;Monad<Meta>
[paired (to-branches branches)]
(&&case;analyse-case analyse input paired))
+ (^ (#;Form (list& [_ (#;Text proc-name)] proc-args)))
+ (&&procedure;analyse-procedure analyse proc-name proc-args)
+
(^template [<tag> <analyser>]
(^ (#;Form (list& [_ (<tag> tag)]
values)))
@@ -101,6 +101,9 @@
([#;Nat &&structure;analyse-sum]
[#;Tag &&structure;analyse-tagged-sum])
+ (#;Tag tag)
+ (&&structure;analyse-tagged-sum analyse tag (' []))
+
(^ (#;Form (list& func args)))
(do meta;Monad<Meta>
[[funcT =func] (&&common;with-unknown-type
diff --git a/new-luxc/source/luxc/analyser/structure.lux b/new-luxc/source/luxc/analyser/structure.lux
index 3bcc04d7e..8c1f7118c 100644
--- a/new-luxc/source/luxc/analyser/structure.lux
+++ b/new-luxc/source/luxc/analyser/structure.lux
@@ -206,19 +206,25 @@
(&;fail "")
))))
-(def: #export (analyse-tagged-sum analyse tag value)
+(def: #export (analyse-tagged-sum analyse tag valueC)
(-> &;Analyser Ident Code (Meta la;Analysis))
(do meta;Monad<Meta>
[tag (meta;normalize tag)
[idx group variantT] (meta;resolve-tag tag)
- #let [case-size (list;size group)]
- inferenceT (&inference;variant-inference-type idx case-size variantT)
- [inferredT valueA+] (&inference;apply-function analyse inferenceT (list value))
- expectedT meta;expected-type
- _ (&;with-type-env
- (tc;check expectedT inferredT))
- temp &scope;next-local]
- (wrap (la;sum idx case-size temp (|> valueA+ list;head maybe;assume)))))
+ expectedT meta;expected-type]
+ (case expectedT
+ (#;Var _)
+ (do @
+ [#let [case-size (list;size group)]
+ inferenceT (&inference;variant-inference-type idx case-size variantT)
+ [inferredT valueA+] (&inference;apply-function analyse inferenceT (list valueC))
+ _ (&;with-type-env
+ (tc;check expectedT inferredT))
+ temp &scope;next-local]
+ (wrap (la;sum idx case-size temp (|> valueA+ list;head maybe;assume))))
+
+ _
+ (analyse-sum analyse idx valueC))))
## There cannot be any ambiguity or improper syntax when analysing
## records, so they must be normalized for further analysis.