From 8bbb7907d6a0ffa05d4b2b9fc6b76a15274de887 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Mon, 27 Apr 2020 20:29:16 -0500 Subject: [PATCH] Run parser error handler in the correct env in run-context. --- src/boot/boot.janet | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index ea676435..13fc2e86 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -2005,6 +2005,13 @@ (def res (resume f resumeval)) (when good (when going (set resumeval (onstatus f res)))))) + (defn parse-err + "Handle parser error in the correct environment" + [p where] + (def f (coro (on-parse-error p where))) + (fiber/setenv f env) + (resume f)) + # Loop (def buf @"") (while going @@ -2022,12 +2029,12 @@ (while (parser/has-more p) (eval1 (parser/produce p))) (when (= (parser/status p) :error) - (on-parse-error p where)))) + (parse-err p where)))) # Check final parser state (while (parser/has-more p) (eval1 (parser/produce p))) (when (= (parser/status p) :error) - (on-parse-error p where)) + (parse-err p where)) (in env :exit-value env))