Skip to content

Commit

Permalink
CLJS-480: reader/*data-readers* bound inconsistently
Browse files Browse the repository at this point in the history
Stop binding reader/*data-readers* haphazardly. Instead bind it to
cljs.tagged-literals/*cljs-data-readesr* only in cljs.analyzer/forms-seq
and make sure to actually capture its value to avoid lazy-seq issues.
  • Loading branch information
swannodette committed Nov 24, 2013
1 parent 3912cfd commit a1514b1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
5 changes: 4 additions & 1 deletion src/clj/cljs/analyzer.clj
Expand Up @@ -1425,12 +1425,15 @@
argument, which the reader will use in any emitted errors."
([f] (forms-seq f (source-path f)))
([f filename]
(let [rdr (readers/indexing-push-back-reader (java.io.PushbackReader. (io/reader f)) 1 filename)
(let [rdr (readers/indexing-push-back-reader
(java.io.PushbackReader. (io/reader f)) 1 filename)
data-readers tags/*cljs-data-readers*
forms-seq*
(fn forms-seq* []
(lazy-seq
(let [eof-sentinel (Object.)
form (binding [*ns* (create-ns *cljs-ns*)
reader/*data-readers* data-readers
reader/*alias-map*
(apply merge
((juxt :requires :require-macros)
Expand Down
1 change: 0 additions & 1 deletion src/clj/cljs/compiler.clj
Expand Up @@ -849,7 +849,6 @@
ana/*cljs-ns* 'cljs.user
ana/*cljs-file* (.getPath ^File src)
reader/*alias-map* (or reader/*alias-map* {})
reader/*data-readers* tags/*cljs-data-readers*
*source-map-data* (when (:source-map opts)
(atom
{:source-map (sorted-map)
Expand Down
31 changes: 15 additions & 16 deletions src/clj/cljs/repl.clj
Expand Up @@ -176,24 +176,23 @@
(print (str "ClojureScript:" ana/*cljs-ns* "> "))
(flush)
(let [form (try
(binding [*data-readers* tags/*cljs-data-readers*]
(if (seq forms)
(first forms)
:cljs/quit))
(if (seq forms)
(first forms)
:cljs/quit)
(catch Exception e
(println (.getMessage e))
read-error))]
(cond
(identical? form read-error) (recur (ana/forms-seq *in* "NO_SOURCE_FILE"))

(= form :cljs/quit) :quit

(and (seq? form) (is-special-fn? (first form)))
(do (apply (get special-fns (first form)) repl-env (rest form))
(newline)
(recur (rest forms)))

:else
(do (eval-and-print repl-env env form)
(recur (rest forms))))))
(identical? form read-error) (recur (ana/forms-seq *in* "NO_SOURCE_FILE"))
(= form :cljs/quit) :quit

(and (seq? form) (is-special-fn? (first form)))
(do (apply (get special-fns (first form)) repl-env (rest form))
(newline)
(recur (rest forms)))

:else
(do (eval-and-print repl-env env form)
(recur (rest forms))))))
(-tear-down repl-env)))))

0 comments on commit a1514b1

Please sign in to comment.