Skip to content
This repository has been archived by the owner on Jan 28, 2019. It is now read-only.

Use errPrintWriter which flushes correctly at REPL #92

Merged
merged 2 commits into from
Mar 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
21 changes: 13 additions & 8 deletions src/clj/clojure/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -4153,16 +4156,17 @@
(= 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")))
(when (and (= op :all)
(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)]
Expand All @@ -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
Expand All @@ -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
Expand Down