From 8dbc34dc612fe1501ddb79da19094b6051798d07 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 11 Dec 2023 19:41:51 -0800 Subject: compiler: handle non-locally-exiting top-level forms. * stdlib/compiler.tl (compile-file-conditionally): When evaluation of a compiled top-level form is not suppressed, there is a risk that it can terminate non-locally, via throwing an exception or performing a block return. The compilation of the file is then aborted. We can do better: using an unwind-protect, we can catch all non-local control transfers out of the form and just ignore them. The motivation for this is that it lets us compile files which call (return-from load ...), without requiring that it be written as (compile-only (return-from load ...)). Other things will work, like compiling a (load "foo") where foo doesn't exist or aborts due to errors. --- stdlib/compiler.tl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl index a837571e..ce28e012 100644 --- a/stdlib/compiler.tl +++ b/stdlib/compiler.tl @@ -2590,7 +2590,10 @@ (fence (isecp symvec %package-manip%))) (when *eval* (let ((pa *package-alist*)) - (sys:vm-execute-toplevel vm-desc) + (block* err-ret + (unwind-protect + (sys:vm-execute-toplevel vm-desc) + (return* err-ret))) (when (neq pa *package-alist*) (set fence t)))) (when (and *emit* (consp form)) -- cgit v1.2.3