diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-12-11 19:41:51 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-12-11 19:41:51 -0800 |
commit | 8dbc34dc612fe1501ddb79da19094b6051798d07 (patch) | |
tree | d1f3202bbccf9579cee17732c55ec44008411dd0 /stdlib/compiler.tl | |
parent | 17f11d14178db6e8367ba598bc2e4a1f0fae4d59 (diff) | |
download | txr-8dbc34dc612fe1501ddb79da19094b6051798d07.tar.gz txr-8dbc34dc612fe1501ddb79da19094b6051798d07.tar.bz2 txr-8dbc34dc612fe1501ddb79da19094b6051798d07.zip |
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.
Diffstat (limited to 'stdlib/compiler.tl')
-rw-r--r-- | stdlib/compiler.tl | 5 |
1 files changed, 4 insertions, 1 deletions
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)) |