From 62a0fa2429e8c0210c360af12e58c8b1e19bd1dd Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Thu, 19 May 2022 17:53:22 -0400 Subject: [PATCH] Add additional asts to errors. --- src/ludus/interpreter.clj | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/ludus/interpreter.clj b/src/ludus/interpreter.clj index 9ba0798..5677650 100644 --- a/src/ludus/interpreter.clj +++ b/src/ludus/interpreter.clj @@ -78,7 +78,7 @@ success (:success match)] (if success (vswap! ctx update-ctx (:ctx match)) - (throw (ex-info (:reason match) {}))) + (throw (ex-info (:reason match) {:ast ast}))) value)) (defn- interpret-if [ast ctx] @@ -198,8 +198,8 @@ (if (contains? prev-value (:value curr)) (get prev-value (:value curr)) (if (= (::data/type prev-value) ::data/ns) - (throw (ex-info (str "Namespace error: no member " (:value curr) " in ns " (::data/name prev-value)) {})) - (throw (ex-info (str "Struct error: no member " (:value curr)) {})))) + (throw (ex-info (str "Namespace error: no member " (:value curr) " in ns " (::data/name prev-value)) {:ast curr})) + (throw (ex-info (str "Struct error: no member " (:value curr)) {:ast curr})))) (get prev-value (:value curr))) (call-fn prev-value (interpret-ast curr ctx) ctx)))) @@ -406,22 +406,9 @@ (def source " - let mytest = { - fn even { - (0) -> true - (n) -> odd (dec (n)) - } + let :foo = :bar - fn odd { - (0) -> false - (n) -> even (dec (n)) - } - - @{odd, even} - } - - mytest :odd (1) - mytest :even (955) + ")