From 3b0cdcb3051bfc901a5dee85573ab639ab98854e Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Tue, 8 Mar 2016 03:00:48 -0600 Subject: [PATCH 1/2] Use errPrintWriter which flushes correctly at REPL Deals with a UX issue where warnings about referring deprecated vars and aliasing deprecated namespaces would not appear correctly at the REPL due to some combination of writer flushing behaviors. --- src/clj/clojure/core.clj | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 556ad071..4976604c 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -4120,6 +4120,9 @@ (or (:pedantic *compiler-options*) (:warn-on-deprecated *compiler-options*))) +(defn ^:private errwriter [] + (clojure.lang.RT/errPrintWriter)) + (defn refer "refers to all public vars of ns, subject to filters. filters can include at most one each of: @@ -4153,7 +4156,8 @@ (= op :refer) refer (= op :only) only :else all) - d-ctx (deprecated? *ns*)] + d-ctx (deprecated? *ns*) + *err* (errwriter)] (when (and to-do (not (instance? clojure.lang.Sequential to-do))) (throw (Exception. ":only/:refer value must be a sequential collection of symbols"))) @@ -4161,8 +4165,8 @@ (not d-ctx) (warn-deprecated?) (deprecated? ns)) - (.write *err* (str "Warning: referring vars from deprecated ns: " (name ns) - " (" *file* ":" *line* ":" *column* ")\n"))) + (.println *err* (str "Warning: referring vars from deprecated ns: " (name ns) + " (" *file* ":" *line* ":" *column* ")"))) (doseq [sym to-do] (when-not (exclude sym) (let [v (nspublics sym)] @@ -4175,8 +4179,8 @@ (not d-ctx) (warn-deprecated?) (not= op :all)) - (.write *err* (str "Warning: referring deprecated var: " v - " (" *file* ":" *line* ":" *column* ")\n"))) + (.println *err* (str "Warning: referring deprecated var: " v + " (" *file* ":" *line* ":" *column* ")"))) (. *ns* (refer (or (rename sym) sym) v))))))) (defn ns-refers @@ -4197,12 +4201,13 @@ {:added "1.0" :static true} [alias namespace-sym] - (let [other (the-ns namespace-sym)] + (let [other (the-ns namespace-sym) + *err* (errwriter)] (when (and (not (deprecated? *ns*)) (warn-deprecated?) (deprecated? other)) - (.write *err* (str "Warning: aliasing deprecated ns: " (name namespace-sym) - " (" *file* ":" *line* ":" *column* ")\n"))) + (.println *err* (str "Warning: aliasing deprecated ns: " (name namespace-sym) + " (" *file* ":" *line* ":" *column* ")"))) (.addAlias *ns* alias other))) (defn ns-aliases From 8d70a378facc51833836fd831e22cef1e74cd02d Mon Sep 17 00:00:00 2001 From: Reid 'arrdem' McKenzie Date: Tue, 8 Mar 2016 03:03:33 -0600 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2c772bb..fcbcbc58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Change Log ### upcoming +- [#92](https://github.com/jaunt-lang/jaunt/pull/92) Fix refer/alias warnings not displaying at the REPL (@arrdem). - [#89](https://github.com/jaunt-lang/jaunt/pull/89) Add ^:once support to Vars (@arrdem). - This changeset enables analysis tooling to distinguish between `Var`s which are bound 'once' and those which are simply bound.