From d370b453fca8be79fa5e70ae4ccd16e192402883 Mon Sep 17 00:00:00 2001 From: Oldes Date: Mon, 29 Apr 2019 11:27:52 +0200 Subject: [PATCH] FIX: Restore original path when DO of a script fails fixes: https://github.com/rebol/rebol-issues/issues/2374 --- src/mezz/sys-base.r | 8 +++++--- src/tests/units/evaluation-test.r3 | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/mezz/sys-base.r b/src/mezz/sys-base.r index 37485dc167..c5be675c81 100644 --- a/src/mezz/sys-base.r +++ b/src/mezz/sys-base.r @@ -84,7 +84,7 @@ do*: func [ "Date:" select hdr 'date ] - also + set/any 'value try [ ; Eval the block or make the module, returned either mod? [ ; Import the module and set the var spec: reduce [hdr data do-needs/no-user hdr] @@ -95,8 +95,10 @@ do*: func [ intern data ; Bind the user script catch/quit either var [[do/next data var]] [data] ] - ; Restore system/script and the dir - all [system/script: :scr dir change-dir dir] + ] + ; Restore system/script and the dir + all [system/script: :scr dir change-dir dir] + value ] ] diff --git a/src/tests/units/evaluation-test.r3 b/src/tests/units/evaluation-test.r3 index 7bf7ba852d..daa0851ecb 100644 --- a/src/tests/units/evaluation-test.r3 +++ b/src/tests/units/evaluation-test.r3 @@ -54,6 +54,14 @@ Rebol [ ===end-group=== +===start-group=== "do script" + --test-- "script with error" + ;@@ https://github.com/rebol/rebol-issues/issues/2374 + dir: what-dir + --assert error? do %units/files/error.r3 + --assert dir = what-dir +===end-group=== + ===start-group=== "do function" --test-- "do-func-1"