Fix line number reporting

This commit is contained in:
Scott Richmond 2022-05-26 18:12:23 -04:00
parent c5a7b5ad46
commit 7beca7e0f6

View File

@ -7,6 +7,7 @@
[ludus.data :as data] [ludus.data :as data]
[ludus.show :as show] [ludus.show :as show]
[ludus.loader :as loader] [ludus.loader :as loader]
[ludus.token :as token]
[clojure.pprint :as pp] [clojure.pprint :as pp]
[clojure.set])) [clojure.set]))
@ -517,7 +518,7 @@
(interpret-ast (::parser/ast parsed) {::file file}) (interpret-ast (::parser/ast parsed) {::file file})
(catch clojure.lang.ExceptionInfo e (catch clojure.lang.ExceptionInfo e
(println "Ludus panicked in" file) (println "Ludus panicked in" file)
(println "On line" (get-in e [:ast :token :line])) (println "On line" (get-in e [:ast :token ::token/line]))
(println (ex-message e)) (println (ex-message e))
(pp/pprint (ex-data e)) (pp/pprint (ex-data e))
(System/exit 67)))) (System/exit 67))))
@ -527,15 +528,13 @@
(interpret-ast (::parser/ast parsed) {}) (interpret-ast (::parser/ast parsed) {})
(catch clojure.lang.ExceptionInfo e (catch clojure.lang.ExceptionInfo e
(println "Ludus panicked!") (println "Ludus panicked!")
(println "On line" (get-in (ex-data e) [:ast :token ::token/line]))
(println (ex-message e)) (println (ex-message e))
(pp/pprint (ex-data e))))) (pp/pprint (ex-data e)))))
(comment (do
(def source " (def source "panic! :oops
fn foo () -> ${1, 2, 3}
let bar = ${1, ...foo (), 3}
") ")