Skip to content

Commit 99ec1ad

Browse files
committed
Merge branch 'master' into str-no-idx-seq
2 parents e485731 + ffacd23 commit 99ec1ad

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,31 @@
267267
"Returns true if x is not nil, false otherwise."
268268
[x] (not (nil? x)))
269269

270+
(defn- pr-opts-fnl [opts]
271+
(if-not (nil? opts)
272+
(:flush-on-newline opts)
273+
*flush-on-newline*))
274+
275+
(defn- pr-opts-readably [opts]
276+
(if-not (nil? opts)
277+
(:readably opts)
278+
*print-readably*))
279+
280+
(defn- pr-opts-meta [opts]
281+
(if-not (nil? opts)
282+
(:meta opts)
283+
*print-meta*))
284+
285+
(defn- pr-opts-dup [opts]
286+
(if-not (nil? opts)
287+
(:dup opts)
288+
*print-dup*))
289+
290+
(defn- pr-opts-len [opts]
291+
(if-not (nil? opts)
292+
(:print-length opts)
293+
*print-length*))
294+
270295
(defn object?
271296
"Returns true if x's constructor is Object"
272297
[x]
@@ -907,7 +932,7 @@
907932
[^not-native obj]
908933
(let [sb (StringBuffer.)
909934
writer (StringBufferWriter. sb)]
910-
(-pr-writer obj writer (pr-opts))
935+
(-pr-writer obj writer nil)
911936
(-flush writer)
912937
(.toString sb)))
913938

@@ -10464,13 +10489,13 @@ reduces them without incurring seq initialization"
1046410489
(-write writer "#")
1046510490
(do
1046610491
(-write writer begin)
10467-
(if (zero? (:print-length opts))
10492+
(if (zero? (pr-opts-len opts))
1046810493
(when (seq coll)
1046910494
(-write writer (or (:more-marker opts) "...")))
1047010495
(do
1047110496
(when (seq coll)
1047210497
(print-one (first coll) writer opts))
10473-
(loop [coll (next coll) n (dec (:print-length opts))]
10498+
(loop [coll (next coll) n (dec (pr-opts-len opts))]
1047410499
(if (and coll (or (nil? n) (not (zero? n))))
1047510500
(do
1047610501
(-write writer sep)
@@ -10514,7 +10539,7 @@ reduces them without incurring seq initialization"
1051410539
(declare print-map)
1051510540

1051610541
(defn print-meta? [opts obj]
10517-
(and (boolean (get opts :meta))
10542+
(and (boolean (pr-opts-meta opts))
1051810543
(implements? IMeta obj)
1051910544
(not (nil? (meta obj)))))
1052010545

@@ -10567,7 +10592,7 @@ reduces them without incurring seq initialization"
1056710592
(pr-sequential-writer writer pr-writer "#js [" " " "]" opts obj)
1056810593

1056910594
(string? obj)
10570-
(if (:readably opts)
10595+
(if (pr-opts-readably opts)
1057110596
(-write writer (quote-string obj))
1057210597
(-write writer obj))
1057310598

@@ -10666,57 +10691,61 @@ reduces them without incurring seq initialization"
1066610691
([] (newline nil))
1066710692
([opts]
1066810693
(string-print "\n")
10669-
(when (get opts :flush-on-newline)
10694+
(when (pr-opts-fnl opts)
1067010695
(flush))))
1067110696

1067210697
(defn pr-str
1067310698
"pr to a string, returning it. Fundamental entrypoint to IPrintWithWriter."
1067410699
[& objs]
10675-
(pr-str-with-opts objs (pr-opts)))
10700+
(pr-str-with-opts objs nil))
1067610701

1067710702
(defn prn-str
1067810703
"Same as pr-str followed by (newline)"
1067910704
[& objs]
10680-
(prn-str-with-opts objs (pr-opts)))
10705+
(prn-str-with-opts objs nil))
1068110706

1068210707
(defn pr
1068310708
"Prints the object(s) using string-print. Prints the
1068410709
object(s), separated by spaces if there is more than one.
1068510710
By default, pr and prn print in a way that objects can be
1068610711
read by the reader"
1068710712
[& objs]
10688-
(pr-with-opts objs (pr-opts)))
10713+
(pr-with-opts objs nil))
1068910714

1069010715
(def ^{:doc
1069110716
"Prints the object(s) using string-print.
1069210717
print and println produce output for human consumption."}
1069310718
print
1069410719
(fn cljs-core-print [& objs]
10695-
(pr-with-opts objs (assoc (pr-opts) :readably false))))
10720+
(binding [*print-readably* false]
10721+
(pr-with-opts objs nil))))
1069610722

1069710723
(defn print-str
1069810724
"print to a string, returning it"
1069910725
[& objs]
10700-
(pr-str-with-opts objs (assoc (pr-opts) :readably false)))
10726+
(binding [*print-readably* false]
10727+
(pr-str-with-opts objs nil)))
1070110728

1070210729
(defn println
1070310730
"Same as print followed by (newline)"
1070410731
[& objs]
10705-
(pr-with-opts objs (assoc (pr-opts) :readably false))
10732+
(binding [*print-readably* false]
10733+
(pr-with-opts objs nil))
1070610734
(when *print-newline*
10707-
(newline (pr-opts))))
10735+
(newline nil)))
1070810736

1070910737
(defn println-str
1071010738
"println to a string, returning it"
1071110739
[& objs]
10712-
(prn-str-with-opts objs (assoc (pr-opts) :readably false)))
10740+
(binding [*print-readably* false]
10741+
(prn-str-with-opts objs nil)))
1071310742

1071410743
(defn prn
1071510744
"Same as pr followed by (newline)."
1071610745
[& objs]
10717-
(pr-with-opts objs (pr-opts))
10746+
(pr-with-opts objs nil)
1071810747
(when *print-newline*
10719-
(newline (pr-opts))))
10748+
(newline nil)))
1072010749

1072110750
(defn- strip-ns
1072210751
[named]

src/main/clojure/cljs/analyzer.cljc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,7 @@
15681568
:throw impl/IGNORE_SYM
15691569
:let (infer-tag env (:body ast))
15701570
:loop (infer-tag env (:body ast))
1571+
:try (infer-tag env (:body ast))
15711572
:do (infer-tag env (:ret ast))
15721573
:fn-method (infer-tag env (:body ast))
15731574
:def (infer-tag env (:init ast))

0 commit comments

Comments
 (0)