1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-26 08:20:27 +00:00

Properly bail on parse and compile errors

If -p flag is not set, we should bail on all three kinds
of errors, not just runtime errors. This includes
parse and compile errors. Before, parse and compile errors
were not properly affected by the :exit parameter to require, which
in turn caused scripts to not bail on parse or compile errors.
This commit is contained in:
Calvin Rose 2019-03-12 20:41:17 -04:00
parent ad5b0a371e
commit 2a5234b390

View File

@ -1644,8 +1644,18 @@ value, one key will be ignored."
(def newenv (make-env))
(put module/loading fullpath true)
(defn chunks [buf _] (file/read f 2048 buf))
(defn bp [&opt x y]
(def ret (bad-parse x y))
(if exit-on-error (os/exit))
ret)
(defn bc [&opt x y z]
(def ret (bad-compile x y z))
(if exit-on-error (os/exit))
ret)
(run-context {:env newenv
:chunks chunks
:on-parse-error bp
:on-compile-error bc
:on-status (fn [f x]
(when (not= (fiber/status f) :dead)
(debug/stacktrace f x)