~ chicken-core (chicken-5) 4678db36bee6bea0b2254679625b723ea7b2607b


commit 4678db36bee6bea0b2254679625b723ea7b2607b
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Sat Jan 27 23:36:35 2024 +0100
Commit:     Mario Domenech Goulart <mario@parenteses.org>
CommitDate: Sun Jan 28 19:27:15 2024 +0100

    Including forms must preserve ##sys#current-source-filename
    
    Found by "Reid": invocation of "k" in ##sys#include-forms-from-file
    must be outside the fluid-binding of ##sys#current-source-filename
    or later inclusions while expanding a body will not see the original,
    outer binding of the var and "include-relative" will refer to the
    wrong original source
    
    Signed-off-by: Mario Domenech Goulart <mario@parenteses.org>

diff --git a/eval.scm b/eval.scm
index 6d01e0f8..92244301 100644
--- a/eval.scm
+++ b/eval.scm
@@ -1170,21 +1170,21 @@
 
 (define ##sys#include-forms-from-file
   (let ((call-with-input-file call-with-input-file)
-	(reverse reverse))
+        (reverse reverse))
     (lambda (filename source k)
       (let ((path (##sys#resolve-include-filename filename #t #f source))
-	    (read-with-source-info chicken.syntax#read-with-source-info)) ; OBSOLETE - after bootstrapping we can get rid of this explicit namespacing
-	(when (not path)
-	  (##sys#signal-hook #:file-error 'include "cannot open file" filename))
-	(when (load-verbose)
-	  (print "; including " path " ..."))
-	(call-with-input-file path
-	  (lambda (in)
-	    (fluid-let ((##sys#current-source-filename path))
-	      (do ((x (read-with-source-info in) (read-with-source-info in))
-		   (xs '() (cons x xs)))
-		  ((eof-object? x)
-		   (k (reverse xs)))))))))))
+            (read-with-source-info chicken.syntax#read-with-source-info)) ; OBSOLETE - after bootstrapping we can get rid of this explicit namespacing
+        (when (not path)
+          (##sys#signal-hook #:file-error 'include "cannot open file" filename))
+        (when (load-verbose)
+          (print "; including " path " ..."))
+        (call-with-input-file path
+          (lambda (in)
+            (k (fluid-let ((##sys#current-source-filename path))
+                 (do ((x (read-with-source-info in) (read-with-source-info in))
+                      (xs '() (cons x xs)))
+                     ((eof-object? x)
+                      (reverse xs)))))))))))
 
 
 ;;; Extensions:
Trap