From b96a22d3ea0295c98c2abf5b591742f104818540 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Thu, 15 May 2025 22:36:41 +0200 Subject: [PATCH] primitive-load after boot uses read-syntax * module/ice-9/boot-9.scm (primitive-load): Define a version in Scheme that uses read-syntax. This allows the expander to be able to access source locations. --- module/ice-9/boot-9.scm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index 101a2755a..d7cef2177 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -4601,7 +4601,22 @@ R7RS." (values read read-syntax))) (lambda (read* read-syntax*) (set! read read*) - (set! read-syntax read-syntax*))) + (set! read-syntax read-syntax*) + + (set! primitive-load + (lambda (file-name) + (when %load-hook + (%load-hook file-name)) + (call-with-input-file file-name + (lambda (port) + (let lp ((expr (read-syntax port))) + (let ((next (read-syntax port))) + (if (eof-object? next) + (primitive-eval expr) + (begin + (primitive-eval expr) + (lp next)))))) + #:encoding "UTF-8" #:guess-encoding #t)))))