From 34530173f951083583b2909638f7dec0607f53bc Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 17 Jul 2011 07:51:12 -0600 Subject: [PATCH] fix `enter!' to set module source name Merge to 5.1.2 (cherry picked from commit 67936b7a66f088f9d49aff3e7e1052b1b7bc99de) --- collects/racket/enter.rkt | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/collects/racket/enter.rkt b/collects/racket/enter.rkt index 79169a5ba0..5efcb187f2 100644 --- a/collects/racket/enter.rkt +++ b/collects/racket/enter.rkt @@ -74,24 +74,30 @@ [path (path->complete-path path dir)] [path (normal-case-path (simplify-path path))]) ;; Record module timestamp and dependencies: + (define-values (ts actual-path) (get-timestamp path)) (let ([a-mod (mod name - (get-timestamp path) + ts (if code (append-map cdr (module-compiled-imports code)) null))]) (hash-set! loaded path a-mod)) ;; Evaluate the module: - (eval code)) + (parameterize ([current-module-declare-source actual-path]) + (eval code))) ;; Not a module: (begin (notify path) (orig path name))))) (define (get-timestamp path) - (file-or-directory-modify-seconds path #f - (lambda () - (if (regexp-match? #rx#"[.]rkt$" (path->bytes path)) - (file-or-directory-modify-seconds - (path-replace-suffix path #".ss") #f (lambda () -inf.0)) - -inf.0)))) + (let ([ts (file-or-directory-modify-seconds path #f (lambda () #f))]) + (if ts + (values ts path) + (if (regexp-match? #rx#"[.]rkt$" (path->bytes path)) + (let* ([alt-path (path-replace-suffix path #".ss")] + [ts (file-or-directory-modify-seconds alt-path #f (lambda () #f))]) + (if ts + (values ts alt-path) + (values -inf.0 path))) + (values -inf.0 path))))) (define (check-latest mod flags) (define mpi (module-path-index-join mod #f)) @@ -106,11 +112,12 @@ (define mod (hash-ref loaded npath #f)) (when mod (for-each loop (mod-depends mod)) - (define ts (get-timestamp npath)) + (define-values (ts actual-path) (get-timestamp npath)) (when (ts . > . (mod-timestamp mod)) (define orig (current-load/use-compiled)) (parameterize ([current-load/use-compiled (enter-load/use-compiled orig #f flags)] - [current-module-declare-name rpath]) + [current-module-declare-name rpath] + [current-module-declare-source actual-path]) ((enter-load/use-compiled orig #t flags) npath (mod-name mod)))))))))