From 5f0f390ca61f4b8eebc99ecd6ef05cead8f2827d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= <georges.duperon@gmail.com>
Date: Thu, 18 Aug 2016 02:07:59 +0200
Subject: [PATCH] Attempt to fix "#%module-begin: cannot use identifier tainted
 by macro transformation" error due to srcloc fix

---
 .travis.yml     |  1 +
 lang/reader.rkt | 24 ++++++++++--------------
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a24ae18..6609f1a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -26,6 +26,7 @@ env:
     # The `debug` package used just for the tests does not work on 6.1 and 6.1.1
     #- RACKET_VERSION=6.1
     #- RACKET_VERSION=6.1.1
+    # in v6.2, error "#%module-begin: cannot use identifier tainted by macro transformation" on files which use #lang repltest typed/racket
     - RACKET_VERSION=6.2
     - RACKET_VERSION=6.3
     - RACKET_VERSION=6.4
diff --git a/lang/reader.rkt b/lang/reader.rkt
index bb947cc..970b062 100644
--- a/lang/reader.rkt
+++ b/lang/reader.rkt
@@ -49,26 +49,22 @@
     (reader chr (narrow-until-prompt in) src line col pos))
   
   (define/with-syntax (mod nam lang (modbeg . body))
-    #;(eval-syntax (replace-top-loc #'(expand #'orig-mod)
-                                    (syntax-source #'here)
-                                    #'orig-mod)
+    #;(eval-syntax (syntax/loc #'orig-mod (expand #'orig-mod))
                    (variable-reference->namespace (#%variable-reference)))
     (parameterize ([current-namespace (variable-reference->namespace
                                        (#%variable-reference))])
       (expand #'orig-mod)))
   
   ;; quasisyntax/loc Necessary so that the generated code has the correct srcloc
-  (replace-top-loc
-   #`(mod nam lang
-          (modbeg
-           (module* test racket/base
-             (require repltest/private/run-interactions)
-             ;; TODO: set-port-next-location! for (open-input-string …)
-             (run-interactions (open-input-string #,(port->string in))
-                               (#%variable-reference)))
-           . body))
-   (syntax-source #'here)
-   #'mod))
+  (quasisyntax/loc #'mod
+    (mod nam lang
+         (modbeg
+          (module* test racket/base
+            (require repltest/private/run-interactions)
+            ;; TODO: set-port-next-location! for (open-input-string …)
+            (run-interactions (open-input-string #,(port->string in))
+                              (#%variable-reference)))
+          . body))))
 
 (define-values (repltest-read repltest-read-syntax repltest-get-info)
   (make-meta-reader