From f73ef8182bebb9344d445edbb2f210ada03c8469 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 3 Jun 2023 23:14:47 -0700 Subject: bug: compile-file can put out nil, confusing load. The file compiler combines compiled forms into a single list as much as possible so that objects in the list can share structure (e.g. merged string literals). However, when package-manipulating forms occur, like defpackage, it has to spit these lists, since the package manipulations of an earlier form affect the processing of a later form, such as whether symbols in that form are valid. This splitting does not take care of the case that an empty piece may result when the very last form is a package manipulation form. A nil gets written to the .tlo file, which the load function does not like; load thinks that since this is not a valid list of compiled forms, it must be the version number field of a catenated .tlo file, and proceeds to find it an invalid, incompatible version. * stdlib/compiler.tl (dump-to-tlo): Use partition* rather than split*. partition* doesn't leave empty pieces. --- stdlib/compiler.tl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/compiler.tl b/stdlib/compiler.tl index fd7b2017..62893e94 100644 --- a/stdlib/compiler.tl +++ b/stdlib/compiler.tl @@ -2448,7 +2448,7 @@ (defun dump-to-tlo (out-stream out) (let* ((*print-circle* t) (*package* (sys:make-anon-package)) - (out-forms (split* out.(get) (op where (op eq :fence))))) + (out-forms (partition* out.(get) (op where (op eq :fence))))) (prinl %tlo-ver% out-stream) [mapdo (op prinl @1 out-stream) out-forms] (delete-package *package*))) -- cgit v1.2.3