aboutsummaryrefslogtreecommitdiff
path: root/luxc/src
diff options
context:
space:
mode:
Diffstat (limited to 'luxc/src')
-rw-r--r--luxc/src/lux.clj2
-rw-r--r--luxc/src/lux/analyser.clj2
-rw-r--r--luxc/src/lux/analyser/base.clj4
-rw-r--r--luxc/src/lux/analyser/case.clj38
-rw-r--r--luxc/src/lux/analyser/env.clj5
-rw-r--r--luxc/src/lux/analyser/lambda.clj2
-rw-r--r--luxc/src/lux/analyser/lux.clj12
-rw-r--r--luxc/src/lux/analyser/meta.clj2
-rw-r--r--luxc/src/lux/analyser/parser.clj2
-rw-r--r--luxc/src/lux/analyser/record.clj2
-rw-r--r--luxc/src/lux/base.clj2
-rw-r--r--luxc/src/lux/compiler.clj6
-rw-r--r--luxc/src/lux/compiler/base.clj2
-rw-r--r--luxc/src/lux/compiler/cache.clj4
-rw-r--r--luxc/src/lux/compiler/cache/ann.clj2
-rw-r--r--luxc/src/lux/compiler/cache/type.clj2
-rw-r--r--luxc/src/lux/compiler/case.clj2
-rw-r--r--luxc/src/lux/compiler/host.clj6
-rw-r--r--luxc/src/lux/compiler/io.clj2
-rw-r--r--luxc/src/lux/compiler/lambda.clj2
-rw-r--r--luxc/src/lux/compiler/lux.clj18
-rw-r--r--luxc/src/lux/compiler/module.clj2
-rw-r--r--luxc/src/lux/compiler/parallel.clj2
-rw-r--r--luxc/src/lux/host.clj2
-rw-r--r--luxc/src/lux/host/generics.clj2
-rw-r--r--luxc/src/lux/lexer.clj2
-rw-r--r--luxc/src/lux/lib/loader.clj2
-rw-r--r--luxc/src/lux/optimizer.clj2
-rw-r--r--luxc/src/lux/parser.clj12
-rw-r--r--luxc/src/lux/reader.clj8
-rw-r--r--luxc/src/lux/repl.clj6
-rw-r--r--luxc/src/lux/type.clj37
-rw-r--r--luxc/src/lux/type/host.clj12
33 files changed, 108 insertions, 100 deletions
diff --git a/luxc/src/lux.clj b/luxc/src/lux.clj
index d17f1640d..a013d2421 100644
--- a/luxc/src/lux.clj
+++ b/luxc/src/lux.clj
@@ -5,7 +5,7 @@
(ns lux
(:gen-class)
- (:require [lux.base :as & :refer [|let |do return fail return* fail* |case]]
+ (:require [lux.base :as & :refer [|let |do return return* |case]]
[lux.compiler.base :as &compiler-base]
[lux.compiler :as &compiler]
[lux.repl :as &repl]
diff --git a/luxc/src/lux/analyser.clj b/luxc/src/lux/analyser.clj
index f47bcf914..f28d55e23 100644
--- a/luxc/src/lux/analyser.clj
+++ b/luxc/src/lux/analyser.clj
@@ -7,7 +7,7 @@
(:require (clojure [template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|let |do return fail return* fail* |case]]
+ (lux [base :as & :refer [|let |do return return* |case]]
[reader :as &reader]
[parser :as &parser]
[type :as &type]
diff --git a/luxc/src/lux/analyser/base.clj b/luxc/src/lux/analyser/base.clj
index ccc7260bc..e5e793c34 100644
--- a/luxc/src/lux/analyser/base.clj
+++ b/luxc/src/lux/analyser/base.clj
@@ -6,7 +6,7 @@
(ns lux.analyser.base
(:require clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [defvariant |let |do return* return fail |case]]
+ (lux [base :as & :refer [defvariant |let |do return* return |case]]
[type :as &type])))
;; [Tags]
@@ -60,7 +60,7 @@
(return x)
_
- (fail "[Analyser Error] Can't expand to other than 1 element."))))
+ (&/fail-with-loc "[Analyser Error] Can't expand to other than 1 element."))))
(defn analyse-1 [analyse exo-type elem]
(&/with-expected-type exo-type
diff --git a/luxc/src/lux/analyser/case.clj b/luxc/src/lux/analyser/case.clj
index 042ca8352..8bb5cca35 100644
--- a/luxc/src/lux/analyser/case.clj
+++ b/luxc/src/lux/analyser/case.clj
@@ -6,7 +6,7 @@
(ns lux.analyser.case
(:require clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [defvariant |do return fail |let |case]]
+ (lux [base :as & :refer [defvariant |do return |let |case]]
[parser :as &parser]
[type :as &type])
(lux.analyser [base :as &&]
@@ -48,7 +48,7 @@
(|case type
(&/$VarT ?id)
(|do [type* (&/try-all% (&/|list (&type/deref ?id)
- (fail "##1##")))]
+ (&/fail-with-loc "##1##")))]
(resolve-type type*))
(&/$UnivQ _)
@@ -185,7 +185,7 @@
(apply-type! =type-fun param))
_
- (fail (str "[Type System] Not a type function:\n" (&type/show-type type-fn) "\n"))))
+ (&/fail-with-loc (str "[Type System] Not a type function:\n" (&type/show-type type-fn) "\n"))))
(defn adjust-type* [up type]
"(-> (List (, (Maybe (List Type)) Int Type)) Type (Lux Type))"
@@ -240,7 +240,7 @@
(&/$VarT ?id)
(|do [type* (&/try-all% (&/|list (&type/deref ?id)
- (fail (str "##2##: " ?id))))]
+ (&/fail-with-loc (str "##2##: " ?id))))]
(adjust-type* up type*))
(&/$NamedT ?name ?type)
@@ -250,7 +250,7 @@
(return type)
_
- (fail (str "[Pattern-matching Error] Can't adjust type: " (&type/show-type type)))
+ (&/fail-with-loc (str "[Pattern-matching Error] Can't adjust type: " (&type/show-type type)))
))
(defn adjust-type [type]
@@ -274,7 +274,7 @@
(return (&/T [($StoreTestAC idx) =kont]))))
(&/$SymbolS ident)
- (fail (str "[Pattern-matching Error] Symbols must be unqualified: " (&/ident->text ident)))
+ (&/fail-with-loc (str "[Pattern-matching Error] Symbols must be unqualified: " (&/ident->text ident)))
(&/$BoolS ?value)
(|do [_ (&type/check value-type &type/Bool)
@@ -340,12 +340,12 @@
(return (&/T [&/$Nil =kont])))
(&/|reverse (&/zip2 _tuple-types ?members)))]
(return (&/T [($TupleTestAC =tests) =kont])))
- (fail (str "[Pattern-matching Error] Pattern-matching mismatch. Require tuple[" (&/|length (&type/flatten-prod value-type*)) "]. Given tuple [" (&/|length ?members) "]"
- " -- " (&/show-ast pattern)
- " " (&type/show-type value-type*) " " (&type/show-type value-type)))))
+ (&/fail-with-loc (str "[Pattern-matching Error] Pattern-matching mismatch. Require tuple[" (&/|length (&type/flatten-prod value-type*)) "]. Given tuple [" (&/|length ?members) "]"
+ " -- " (&/show-ast pattern)
+ " " (&type/show-type value-type*) " " (&type/show-type value-type)))))
_
- (fail (str "[Pattern-matching Error] Tuples require tuple-types: " (&type/show-type value-type))))))
+ (&/fail-with-loc (str "[Pattern-matching Error] Tuples require tuple-types: " (&type/show-type value-type))))))
(&/$RecordS pairs)
(|do [[rec-members rec-type] (&&record/order-record pairs)
@@ -403,7 +403,7 @@
(return (&/T [($VariantTestAC (&/T [idx (&/|length group) =test])) =kont])))
_
- (fail (str "[Pattern-matching Error] Unrecognized pattern syntax: " (&/show-ast pattern)))
+ (&/fail-with-loc (str "[Pattern-matching Error] Unrecognized pattern syntax: " (&/show-ast pattern)))
)))
(defn ^:private analyse-branch [analyse exo-type var?? value-type pattern body patterns]
@@ -528,7 +528,7 @@
(merge-total v (&/T [t ?body])))
?values ?tests)]
(return ($TupleTotal total? structs)))
- (fail "[Pattern-matching Error] Inconsistent tuple-size."))
+ (&/fail-with-loc "[Pattern-matching Error] Inconsistent tuple-size."))
[($DefaultTotal total?) ($VariantTestAC ?tag ?count ?test)]
(|do [sub-struct (merge-total ($DefaultTotal total?)
@@ -538,7 +538,7 @@
(return list)
(&/$None)
- (fail "[Pattern-matching Error] YOLO"))]
+ (&/fail-with-loc "[Pattern-matching Error] YOLO"))]
(return ($VariantTotal total? structs)))
[($VariantTotal total? ?branches) ($VariantTestAC ?tag ?count ?test)]
@@ -554,7 +554,7 @@
(return list)
(&/$None)
- (fail "[Pattern-matching Error] YOLO"))]
+ (&/fail-with-loc "[Pattern-matching Error] YOLO"))]
(return ($VariantTotal total? structs)))
)))
@@ -610,7 +610,7 @@
(return true)
_
- (fail "[Pattern-maching Error] Unit is not total.")))
+ (&/fail-with-loc "[Pattern-maching Error] Unit is not total.")))
_
(|do [unknown? (&type/unknown? value-type)]
@@ -632,10 +632,10 @@
(if (= num-elems _shorter)
(|do [totals (&/map2% check-totality _tuple-types ?structs)]
(return (&/fold #(and %1 %2) true totals)))
- (fail (str "[Pattern-maching Error] Tuple-mismatch. Require tuple[" (&/|length (&type/flatten-prod value-type*)) "]. Given tuple [" (&/|length ?structs) "]"))))
+ (&/fail-with-loc (str "[Pattern-maching Error] Tuple-mismatch. Require tuple[" (&/|length (&type/flatten-prod value-type*)) "]. Given tuple [" (&/|length ?structs) "]"))))
_
- (fail (str "[Pattern-maching Error] Tuple is not total." " - " (&type/show-type value-type*)))))))))
+ (&/fail-with-loc (str "[Pattern-maching Error] Tuple is not total." " - " (&type/show-type value-type*)))))))))
($VariantTotal ?total ?structs)
(if ?total
@@ -649,7 +649,7 @@
(return (&/fold #(and %1 %2) true totals)))
_
- (fail "[Pattern-maching Error] Variant is not total."))))
+ (&/fail-with-loc "[Pattern-maching Error] Variant is not total."))))
))
;; [Exports]
@@ -663,4 +663,4 @@
? (check-totality value-type struct)]
(if ?
(return patterns)
- (fail "[Pattern-maching Error] Pattern-matching is non-total."))))
+ (&/fail-with-loc "[Pattern-maching Error] Pattern-matching is non-total."))))
diff --git a/luxc/src/lux/analyser/env.clj b/luxc/src/lux/analyser/env.clj
index 75e066e34..5c0133821 100644
--- a/luxc/src/lux/analyser/env.clj
+++ b/luxc/src/lux/analyser/env.clj
@@ -6,7 +6,7 @@
(ns lux.analyser.env
(:require clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return return* fail fail* |case]])
+ (lux [base :as & :refer [|do return return* |case]])
[lux.analyser.base :as &&]))
;; [Exports]
@@ -67,7 +67,8 @@
(fn [state]
(|case (&/get$ &/$scopes state)
(&/$Nil)
- (fail* "[Analyser Error] Can't obtain captured vars without environments.")
+ ((&/fail-with-loc "[Analyser Error] Can't obtain captured vars without environments.")
+ state)
(&/$Cons env _)
(return* state (->> env (&/get$ &/$closure) (&/get$ &/$mappings))))
diff --git a/luxc/src/lux/analyser/lambda.clj b/luxc/src/lux/analyser/lambda.clj
index b47b803d0..b460a2e18 100644
--- a/luxc/src/lux/analyser/lambda.clj
+++ b/luxc/src/lux/analyser/lambda.clj
@@ -6,7 +6,7 @@
(ns lux.analyser.lambda
(:require clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|let |do return fail |case]]
+ (lux [base :as & :refer [|let |do return |case]]
[host :as &host])
(lux.analyser [base :as &&]
[env :as &env])))
diff --git a/luxc/src/lux/analyser/lux.clj b/luxc/src/lux/analyser/lux.clj
index 7ca31f322..2d439dd03 100644
--- a/luxc/src/lux/analyser/lux.clj
+++ b/luxc/src/lux/analyser/lux.clj
@@ -8,7 +8,7 @@
[set :as set])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return return* fail fail* |let |list |case]]
+ (lux [base :as & :refer [|do return return* |let |list |case]]
[parser :as &parser]
[type :as &type]
[host :as &host])
@@ -298,8 +298,10 @@
state)
_
- (fail* "[Analyser Error] Can't have anything other than a global def in the global environment."))
- (fail* (str "[Analyser Error] Unknown global definition: " name)))
+ ((&/fail-with-loc "[Analyser Error] Can't have anything other than a global def in the global environment.")
+ state))
+ ((&/fail-with-loc (str "[Analyser Error] Unknown global definition: " name))
+ state))
(&/$Cons bottom-outer _)
(|let [scopes (&/|map #(&/get$ &/$name %) (&/|reverse inner))
@@ -524,7 +526,7 @@
(&&/$lambda register-offset =scope =captured =body))))
_
- (fail "")))
+ (&/fail "")))
(fn [err]
(&/fail-with-loc (str err "\n" "[Analyser Error] Functions require function types: " (&type/show-type exo-type)))))
))
@@ -675,7 +677,7 @@
(set-compiler (merge-compilers current-module _new-compiler compiler))
(&/$Left ?error)
- (fail ?error)))
+ (&/fail ?error)))
_compiler
=asyncs)]
(return &/$Nil)))
diff --git a/luxc/src/lux/analyser/meta.clj b/luxc/src/lux/analyser/meta.clj
index 20bbaef68..931558374 100644
--- a/luxc/src/lux/analyser/meta.clj
+++ b/luxc/src/lux/analyser/meta.clj
@@ -7,7 +7,7 @@
(:require (clojure [template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|let |do return return* fail fail* |case]])))
+ (lux [base :as & :refer [|let |do return return* |case]])))
;; [Utils]
(defn ^:private ident= [x y]
diff --git a/luxc/src/lux/analyser/parser.clj b/luxc/src/lux/analyser/parser.clj
index 586806942..b52abacee 100644
--- a/luxc/src/lux/analyser/parser.clj
+++ b/luxc/src/lux/analyser/parser.clj
@@ -7,7 +7,7 @@
(:require (clojure [template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return* return fail fail* |let |case]]
+ (lux [base :as & :refer [|do return* return |let |case]]
[reader :as &reader]
[lexer :as &lexer]
[parser :as &parser])))
diff --git a/luxc/src/lux/analyser/record.clj b/luxc/src/lux/analyser/record.clj
index 81332b34c..4b3e9243d 100644
--- a/luxc/src/lux/analyser/record.clj
+++ b/luxc/src/lux/analyser/record.clj
@@ -6,7 +6,7 @@
(ns lux.analyser.record
(:require clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|let |do return fail |case]]
+ (lux [base :as & :refer [|let |do return |case]]
[type :as &type])
(lux.analyser [base :as &&]
[module :as &&module])))
diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj
index f893f3a02..f47677852 100644
--- a/luxc/src/lux/base.clj
+++ b/luxc/src/lux/base.clj
@@ -667,7 +667,7 @@
((exhaust% step) state*)
($Left msg)
- (if (.equals "[Reader Error] EOF" msg)
+ (if (.contains msg "[Reader Error] EOF")
(return* state unit-tag)
(fail* msg)))))
diff --git a/luxc/src/lux/compiler.clj b/luxc/src/lux/compiler.clj
index 0c30c76e9..91dde8898 100644
--- a/luxc/src/lux/compiler.clj
+++ b/luxc/src/lux/compiler.clj
@@ -10,7 +10,7 @@
[template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|let |do return* return fail fail* |case]]
+ (lux [base :as & :refer [|let |do return* return |case]]
[type :as &type]
[reader :as &reader]
[lexer :as &lexer]
@@ -186,7 +186,7 @@
(let [compiler-step (&analyser/analyse &optimizer/optimize eval! compile-module!! all-compilers)]
(|do [module-exists? (&a-module/exists? name)]
(if module-exists?
- (fail "[Compiler Error] Can't redefine a module!")
+ (&/fail-with-loc "[Compiler Error] Can't redefine a module!")
(|do [_ (&&cache/delete name)
_ (&a-module/create-module name file-hash)
_ (&/flag-active-module name)
@@ -250,7 +250,7 @@
?state)
(&/$Left ?message)
- (fail* ?message))))))))
+ (&/fail* ?message))))))))
)
)))
diff --git a/luxc/src/lux/compiler/base.clj b/luxc/src/lux/compiler/base.clj
index 1e508f6ea..9a990d9fc 100644
--- a/luxc/src/lux/compiler/base.clj
+++ b/luxc/src/lux/compiler/base.clj
@@ -9,7 +9,7 @@
[clojure.java.io :as io]
[clojure.core.match :as M :refer [matchv]]
clojure.core.match.array
- (lux [base :as & :refer [|let |do return* return fail fail*]]
+ (lux [base :as & :refer [|let |do return* return fail*]]
[type :as &type]
[host :as &host])
(lux.analyser [base :as &a]
diff --git a/luxc/src/lux/compiler/cache.clj b/luxc/src/lux/compiler/cache.clj
index 436f778f5..3d09a9c88 100644
--- a/luxc/src/lux/compiler/cache.clj
+++ b/luxc/src/lux/compiler/cache.clj
@@ -9,7 +9,7 @@
[clojure.java.io :as io]
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return* return fail fail* |case |let]]
+ (lux [base :as & :refer [|do return* return |case |let]]
[type :as &type]
[host :as &host])
[lux.host.generics :as &host-generics]
@@ -276,4 +276,4 @@
(|do [_ (inject-module module-name module-struct)
_ (&/flag-cached-module module-name)]
(return nil))
- (fail (str "[Cache Error] Module is not cached: " module-name))))
+ (&/fail (str "[Cache Error] Module is not cached: " module-name))))
diff --git a/luxc/src/lux/compiler/cache/ann.clj b/luxc/src/lux/compiler/cache/ann.clj
index e2df55286..a4dbb1605 100644
--- a/luxc/src/lux/compiler/cache/ann.clj
+++ b/luxc/src/lux/compiler/cache/ann.clj
@@ -8,7 +8,7 @@
[string :as string])
[clojure.core.match :as M :refer [matchv]]
clojure.core.match.array
- (lux [base :as & :refer [|let |do return* return fail fail* |case]])))
+ (lux [base :as & :refer [|let |do return* return |case]])))
(def ^:private stop (->> 7 char str))
(def ^:private cons-signal (->> 5 char str))
diff --git a/luxc/src/lux/compiler/cache/type.clj b/luxc/src/lux/compiler/cache/type.clj
index eb82e162f..18440b6fc 100644
--- a/luxc/src/lux/compiler/cache/type.clj
+++ b/luxc/src/lux/compiler/cache/type.clj
@@ -8,7 +8,7 @@
[string :as string])
[clojure.core.match :as M :refer [matchv]]
clojure.core.match.array
- (lux [base :as & :refer [|let |do return* return fail fail* |case]]
+ (lux [base :as & :refer [|let |do return* return |case]]
[type :as &type])))
(def ^:private stop (->> 7 char str))
diff --git a/luxc/src/lux/compiler/case.clj b/luxc/src/lux/compiler/case.clj
index 416c93622..1bc87ff9b 100644
--- a/luxc/src/lux/compiler/case.clj
+++ b/luxc/src/lux/compiler/case.clj
@@ -8,7 +8,7 @@
[template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return* return fail fail* |let |case]]
+ (lux [base :as & :refer [|do return* return |let |case]]
[type :as &type]
[lexer :as &lexer]
[parser :as &parser]
diff --git a/luxc/src/lux/compiler/host.clj b/luxc/src/lux/compiler/host.clj
index 10a718093..5b8703a51 100644
--- a/luxc/src/lux/compiler/host.clj
+++ b/luxc/src/lux/compiler/host.clj
@@ -9,7 +9,7 @@
[template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return* return fail fail* |let |case]]
+ (lux [base :as & :refer [|do return* return |let |case]]
[type :as &type]
[lexer :as &lexer]
[parser :as &parser]
@@ -2807,7 +2807,7 @@
"s2l" (compile-jvm-s2l compile ?values special-args)
"b2l" (compile-jvm-b2l compile ?values special-args)
;; else
- (fail (str "[Compiler Error] Unknown host procedure: " [proc-category proc-name])))
+ (&/fail-with-loc (str "[Compiler Error] Unknown host procedure: " [proc-category proc-name])))
;; else
- (fail (str "[Compiler Error] Unknown host procedure: " [proc-category proc-name]))))
+ (&/fail-with-loc (str "[Compiler Error] Unknown host procedure: " [proc-category proc-name]))))
diff --git a/luxc/src/lux/compiler/io.clj b/luxc/src/lux/compiler/io.clj
index aea1c352d..6e5aced34 100644
--- a/luxc/src/lux/compiler/io.clj
+++ b/luxc/src/lux/compiler/io.clj
@@ -4,7 +4,7 @@
;; You can obtain one at http://mozilla.org/MPL/2.0/.
(ns lux.compiler.io
- (:require (lux [base :as & :refer [|case |let |do return* return fail fail*]])
+ (:require (lux [base :as & :refer [|case |let |do return* return fail*]])
(lux.compiler [base :as &&])
[lux.lib.loader :as &lib]))
diff --git a/luxc/src/lux/compiler/lambda.clj b/luxc/src/lux/compiler/lambda.clj
index c0096523f..82e4979bb 100644
--- a/luxc/src/lux/compiler/lambda.clj
+++ b/luxc/src/lux/compiler/lambda.clj
@@ -9,7 +9,7 @@
[template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return* return fail fail* |case |let]]
+ (lux [base :as & :refer [|do return* return |case |let]]
[type :as &type]
[lexer :as &lexer]
[parser :as &parser]
diff --git a/luxc/src/lux/compiler/lux.clj b/luxc/src/lux/compiler/lux.clj
index fd4130707..222c40a9d 100644
--- a/luxc/src/lux/compiler/lux.clj
+++ b/luxc/src/lux/compiler/lux.clj
@@ -9,7 +9,7 @@
[template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return* return fail fail* |let |case]]
+ (lux [base :as & :refer [|do return* return |let |case]]
[type :as &type]
[lexer :as &lexer]
[parser :as &parser]
@@ -270,10 +270,10 @@
_ (&/without-repl-closure
(&a-module/define module-name ?name def-type def-meta def-value))]
(return nil))
- (fail (str "[Compilation Error] Aliases cannot contain meta-data: " module-name ";" ?name)))
+ (&/fail-with-loc (str "[Compilation Error] Aliases cannot contain meta-data: " module-name ";" ?name)))
(&/$Some _)
- (fail "[Compilation Error] Invalid syntax for lux;alias meta-data. Must be an Ident.")
+ (&/fail-with-loc "[Compilation Error] Invalid syntax for lux;alias meta-data. Must be an Ident.")
_
(|case (de-ann ?body)
@@ -336,16 +336,16 @@
(return tag)
_
- (fail "[Compiler Error] Incorrect format for tags.")))
+ (&/fail-with-loc "[Compiler Error] Incorrect format for tags.")))
tags*)
_ (&a-module/declare-tags module-name tags was-exported? def-value)]
(return nil))
[false (&/$Some _)]
- (fail "[Compiler Error] Can't define tags for non-type.")
+ (&/fail-with-loc "[Compiler Error] Can't define tags for non-type.")
[true (&/$Some _)]
- (fail "[Compiler Error] Incorrect format for tags.")
+ (&/fail-with-loc "[Compiler Error] Incorrect format for tags.")
[_ (&/$None)]
(return nil))
@@ -407,16 +407,16 @@
(return tag)
_
- (fail "[Compiler Error] Incorrect format for tags.")))
+ (&/fail-with-loc "[Compiler Error] Incorrect format for tags.")))
tags*)
_ (&a-module/declare-tags module-name tags was-exported? def-value)]
(return nil))
[false (&/$Some _)]
- (fail "[Compiler Error] Can't define tags for non-type.")
+ (&/fail-with-loc "[Compiler Error] Can't define tags for non-type.")
[true (&/$Some _)]
- (fail "[Compiler Error] Incorrect format for tags.")
+ (&/fail-with-loc "[Compiler Error] Incorrect format for tags.")
[_ (&/$None)]
(return nil))
diff --git a/luxc/src/lux/compiler/module.clj b/luxc/src/lux/compiler/module.clj
index 03bc311f2..445876e1f 100644
--- a/luxc/src/lux/compiler/module.clj
+++ b/luxc/src/lux/compiler/module.clj
@@ -9,7 +9,7 @@
[template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|let |do return* return fail fail* |case]]
+ (lux [base :as & :refer [|let |do return* return |case]]
[type :as &type])
[lux.analyser.module :as &module]))
diff --git a/luxc/src/lux/compiler/parallel.clj b/luxc/src/lux/compiler/parallel.clj
index 8f6fee99d..08f780a90 100644
--- a/luxc/src/lux/compiler/parallel.clj
+++ b/luxc/src/lux/compiler/parallel.clj
@@ -9,7 +9,7 @@
[template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|let |do return* return fail fail* |case]])))
+ (lux [base :as & :refer [|let |do return* return |case]])))
;; [Utils]
(def ^:private !state! (ref {}))
diff --git a/luxc/src/lux/host.clj b/luxc/src/lux/host.clj
index 39e659964..5a9fade72 100644
--- a/luxc/src/lux/host.clj
+++ b/luxc/src/lux/host.clj
@@ -8,7 +8,7 @@
[template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return* return fail fail* |let |case]]
+ (lux [base :as & :refer [|do return* return |let |case]]
[type :as &type])
[lux.type.host :as &host-type]
[lux.host.generics :as &host-generics])
diff --git a/luxc/src/lux/host/generics.clj b/luxc/src/lux/host/generics.clj
index cfd0d2d54..70912f9d0 100644
--- a/luxc/src/lux/host/generics.clj
+++ b/luxc/src/lux/host/generics.clj
@@ -8,7 +8,7 @@
[template :refer [do-template]])
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return* return fail fail* |let |case]]))
+ (lux [base :as & :refer [|do return* return |let |case]]))
(:import java.util.regex.Pattern))
(declare gclass->signature)
diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj
index 9dc77b411..579fc3fad 100644
--- a/luxc/src/lux/lexer.clj
+++ b/luxc/src/lux/lexer.clj
@@ -6,7 +6,7 @@
(ns lux.lexer
(:require (clojure [template :refer [do-template]]
[string :as string])
- (lux [base :as & :refer [defvariant |do return* return fail fail* |case]]
+ (lux [base :as & :refer [defvariant |do return* return |case]]
[reader :as &reader])
[lux.analyser.module :as &module]))
diff --git a/luxc/src/lux/lib/loader.clj b/luxc/src/lux/lib/loader.clj
index e8310f9f0..1e160746d 100644
--- a/luxc/src/lux/lib/loader.clj
+++ b/luxc/src/lux/lib/loader.clj
@@ -5,7 +5,7 @@
(ns lux.lib.loader
(:refer-clojure :exclude [load])
- (:require (lux [base :as & :refer [|let |do return fail return* fail* |case]]))
+ (:require (lux [base :as & :refer [|let |do return return* |case]]))
(:import (java.io InputStream
File
FileInputStream
diff --git a/luxc/src/lux/optimizer.clj b/luxc/src/lux/optimizer.clj
index 8ce8fc20e..88d0a68b3 100644
--- a/luxc/src/lux/optimizer.clj
+++ b/luxc/src/lux/optimizer.clj
@@ -3,7 +3,7 @@
;; If a copy of the MPL was not distributed with this file,
;; You can obtain one at http://mozilla.org/MPL/2.0/.
(ns lux.optimizer
- (:require (lux [base :as & :refer [|let |do return fail return* fail* |case defvariant]])
+ (:require (lux [base :as & :refer [|let |do return return* |case defvariant]])
(lux.analyser [base :as &a]
[case :as &a-case])))
diff --git a/luxc/src/lux/parser.clj b/luxc/src/lux/parser.clj
index c32528096..1b56cf213 100644
--- a/luxc/src/lux/parser.clj
+++ b/luxc/src/lux/parser.clj
@@ -18,14 +18,10 @@
(fn [state]
(|case (action state)
(&/$Left ^String error)
- (cond (.contains error base-uneven-record-error)
- (&/$Left error)
-
- (not (.contains error "[Parser Error]"))
- (&/$Left error)
-
- :else
- (&/$Right (&/T [state &/$Nil])))
+ (if (or (.contains error base-uneven-record-error)
+ (not (.contains error "[Parser Error]")))
+ (&/$Left error)
+ (&/$Right (&/T [state &/$Nil])))
(&/$Right state* head)
((|do [tail (repeat% action)]
diff --git a/luxc/src/lux/reader.clj b/luxc/src/lux/reader.clj
index 5a7734061..43875ed95 100644
--- a/luxc/src/lux/reader.clj
+++ b/luxc/src/lux/reader.clj
@@ -7,7 +7,7 @@
(:require [clojure.string :as string]
clojure.core.match
clojure.core.match.array
- [lux.base :as & :refer [defvariant |do return* return fail* |let |case]]))
+ [lux.base :as & :refer [defvariant |do return* return |let |case]]))
;; [Tags]
(defvariant
@@ -20,8 +20,8 @@
(fn [state]
(|case (&/get$ &/$source state)
(&/$Nil)
- (fail* "[Reader Error] EOF")
-
+ ((&/fail-with-loc "[Reader Error] EOF") state)
+
(&/$Cons [[file-name line-num column-num] line]
more)
(|case (body file-name line-num column-num line)
@@ -135,7 +135,7 @@
(|let [old-source (&/get$ &/$source state)]
(|case (body (&/set$ &/$source (from name content) state))
(&/$Left error)
- (&/$Left error)
+ ((&/fail-with-loc error) state)
(&/$Right state* output)
(&/$Right (&/T [(&/set$ &/$source old-source state*) output]))))))
diff --git a/luxc/src/lux/repl.clj b/luxc/src/lux/repl.clj
index 1c727f246..28f820693 100644
--- a/luxc/src/lux/repl.clj
+++ b/luxc/src/lux/repl.clj
@@ -6,7 +6,7 @@
(ns lux.repl
(:require clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|let |do return* return fail fail* |case]]
+ (lux [base :as & :refer [|let |do return* return |case]]
[type :as &type]
[analyser :as &analyser]
[optimizer :as &optimizer]
@@ -46,7 +46,9 @@
?state)
(&/$Left ?message)
- (assert false ?message))
+ (do (println (str "Initialization failed:\n" ?message))
+ (flush)
+ (System/exit 1)))
))
;; [Values]
diff --git a/luxc/src/lux/type.clj b/luxc/src/lux/type.clj
index 099682775..6f91cfa01 100644
--- a/luxc/src/lux/type.clj
+++ b/luxc/src/lux/type.clj
@@ -8,7 +8,7 @@
(:require [clojure.template :refer [do-template]]
clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return* return fail fail* assert! |let |case]])
+ (lux [base :as & :refer [|do return* return assert! |let |case]])
[lux.type.host :as &&host]))
(declare show-type
@@ -170,7 +170,8 @@
(&/$None)
(return* state false))
- (fail* (str "[Type Error] <bound?> Unknown type-var: " id)))))
+ ((&/fail-with-loc (str "[Type Error] <bound?> Unknown type-var: " id))
+ state))))
(defn deref [id]
(fn [state]
@@ -180,8 +181,10 @@
(return* state type)
(&/$None)
- (fail* (str "[Type Error] Unbound type-var: " id)))
- (fail* (str "[Type Error] <deref> Unknown type-var: " id)))))
+ ((&/fail-with-loc (str "[Type Error] Unbound type-var: " id))
+ state))
+ ((&/fail-with-loc (str "[Type Error] <deref> Unknown type-var: " id))
+ state))))
(defn deref+ [type]
(|case type
@@ -189,7 +192,7 @@
(deref id)
_
- (fail (str "[Type Error] Type is not a variable: " (show-type type)))
+ (&/fail-with-loc (str "[Type Error] Type is not a variable: " (show-type type)))
))
(defn set-var [id type]
@@ -199,14 +202,16 @@
(&/$Some bound)
(if (type= type bound)
(return* state nil)
- (fail* (str "[Type Error] Can't re-bind type var: " id " | Current type: " (show-type bound))))
+ ((&/fail-with-loc (str "[Type Error] Can't re-bind type var: " id " | Current type: " (show-type bound)))
+ state))
(&/$None)
(return* (&/update$ &/$type-vars (fn [ts] (&/update$ &/$mappings #(&/|put id (&/$Some type) %)
ts))
state)
nil))
- (fail* (str "[Type Error] <set-var> Unknown type-var: " id " | " (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length))))))
+ ((&/fail-with-loc (str "[Type Error] <set-var> Unknown type-var: " id " | " (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length)))
+ state))))
(defn reset-var [id type]
(fn [state]
@@ -215,7 +220,8 @@
ts))
state)
nil)
- (fail* (str "[Type Error] <set-var> Unknown type-var: " id " | " (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length))))))
+ ((&/fail-with-loc (str "[Type Error] <set-var> Unknown type-var: " id " | " (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length)))
+ state))))
(defn unset-var [id]
(fn [state]
@@ -224,7 +230,8 @@
ts))
state)
nil)
- (fail* (str "[Type Error] <set-var> Unknown type-var: " id " | " (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length))))))
+ ((&/fail-with-loc (str "[Type Error] <set-var> Unknown type-var: " id " | " (->> state (&/get$ &/$type-vars) (&/get$ &/$mappings) &/|length)))
+ state))))
;; [Exports]
;; Type vars
@@ -352,7 +359,7 @@
(clean* ?id type)
_
- (fail (str "[Type Error] Not type-var: " (show-type tvar)))))
+ (&/fail-with-loc (str "[Type Error] Not type-var: " (show-type tvar)))))
(defn ^:private unravel-fun [type]
(|case type
@@ -394,10 +401,10 @@
[1 (<tag> ?left* _)] (return ?left*)
[1 _] (return ?right)
[_ (<tag> _ _)] (<at> (dec tag) ?right)
- _ (fail (str "[Type Error] " <desc> " lacks member: " tag " | " (show-type type))))
+ _ (&/fail-with-loc (str "[Type Error] " <desc> " lacks member: " tag " | " (show-type type))))
_
- (fail (str "[Type Error] Type is not a " <desc> ": " (show-type type))))))
+ (&/fail-with-loc (str "[Type Error] Type is not a " <desc> ": " (show-type type))))))
&/$SumT flatten-sum sum-at "Sum"
&/$ProdT flatten-prod prod-at "Product"
@@ -640,7 +647,7 @@
(apply-type =type-fun param))
_
- (fail (str "[Type System] Not a type function:\n" (show-type type-fn) "\n"))))
+ (&/fail-with-loc (str "[Type System] Not a type function:\n" (show-type type-fn) "\n"))))
(def ^:private init-fixpoints &/$Nil)
@@ -843,7 +850,7 @@
(check* class-loader fixpoints invariant?? expected ?atype)
[_ _]
- (fail ""))
+ (&/fail ""))
(fn [err]
(check-error err expected actual)))))
@@ -877,7 +884,7 @@
(return name)
_
- (fail (str "[Type Error] Type is not named: " (show-type type)))
+ (&/fail-with-loc (str "[Type Error] Type is not named: " (show-type type)))
))
(defn unknown? [type]
diff --git a/luxc/src/lux/type/host.clj b/luxc/src/lux/type/host.clj
index 33073fa34..0f2ffde63 100644
--- a/luxc/src/lux/type/host.clj
+++ b/luxc/src/lux/type/host.clj
@@ -6,7 +6,7 @@
(ns lux.type.host
(:require clojure.core.match
clojure.core.match.array
- (lux [base :as & :refer [|do return* return fail fail* assert! |let |case]])
+ (lux [base :as & :refer [|do return* return assert! |let |case]])
[lux.host.generics :as &host-generics])
(:import (java.lang.reflect GenericArrayType
ParameterizedType
@@ -119,7 +119,7 @@
(let [gvar (.getName ^TypeVariable refl-type)]
(if-let [m-type (&/|get gvar matchings)]
(return m-type)
- (fail (str "[Type Error] Unknown generic type variable: " gvar " -- " (->> matchings
+ (&/fail-with-loc (str "[Type Error] Unknown generic type variable: " gvar " -- " (->> matchings
(&/|map &/|first)
&/->seq)))))
@@ -180,7 +180,7 @@
(&/$GenericTypeVar var-name)
(if-let [m-type (&/|get var-name matchings)]
(return m-type)
- (fail (str "[Type Error] Unknown generic type variable: " var-name " -- " (->> matchings
+ (&/fail-with-loc (str "[Type Error] Unknown generic type variable: " var-name " -- " (->> matchings
(&/|map &/|first)
&/->seq))))
@@ -236,7 +236,7 @@
(let [lineage (trace-lineage sub-class+ super-class+)]
(|do [[^Class sub-class* sub-params*] (raise existential lineage sub-class+ sub-params)]
(return (&/$HostT (.getName sub-class*) sub-params*))))
- (fail (str "[Type Error] Classes don't have a subtyping relationship: " sub-class " </= " super-class)))))
+ (&/fail-with-loc (str "[Type Error] Classes don't have a subtyping relationship: " sub-class " </= " super-class)))))
(defn as-obj [class]
(case class
@@ -284,14 +284,14 @@
(if (= (&/|length e!params) (&/|length a!params))
(|do [_ (&/map2% check e!params a!params)]
(return fixpoints))
- (fail (str "[Type Error] Amounts of generic parameters don't match: " e!name "(" (&/|length e!params) ")" " vs " a!name "(" (&/|length a!params) ")")))
+ (&/fail-with-loc (str "[Type Error] Amounts of generic parameters don't match: " e!name "(" (&/|length e!params) ")" " vs " a!name "(" (&/|length a!params) ")")))
(not invariant??)
(|do [actual* (->super-type existential class-loader e!name a!name a!params)]
(check (&/$HostT e!name e!params) actual*))
:else
- (fail (str "[Type Error] Names don't match: " e!name " =/= " a!name)))))
+ (&/fail-with-loc (str "[Type Error] Names don't match: " e!name " =/= " a!name)))))
(catch Exception e
(prn 'check-host-types e [e!name a!name])
(throw e)))))