所以问题在于 clojure.pprint/pprint-let
中的 pprint-logical-block
将两个分支都包裹起来,而它不应该这样做,因为 pprint-simple-code-list
已经生成了括号。
这里添加一个补丁
From 1761194420c8befe62a6e12cabfd4483b645b703 Mon Sep 17 00:00:00 2001
From: Juan Monetta <[email protected]>
Date: Fri, 10 Nov 2023 11:19:02 -0300
Subject: [PATCH] Fix clojure.pprint pprint-let when form doesn't contain
bindings
---
src/clj/clojure/pprint/dispatch.clj | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/clj/clojure/pprint/dispatch.clj b/src/clj/clojure/pprint/dispatch.clj
index 965c0b25..cd1c2b29 100644
--- a/src/clj/clojure/pprint/dispatch.clj
+++ b/src/clj/clojure/pprint/dispatch.clj
@@ -335,13 +335,14 @@
(defn- pprint-let [alis]
(let [base-sym (first alis)]
- (pprint-logical-block :prefix "(" :suffix ")"
- (if (and (next alis) (vector? (second alis)))
- (do
- ((formatter-out "~w ~1I~@_") base-sym)
- (pprint-binding-form (second alis))
- ((formatter-out " ~_~{~w~^ ~_~}") (next (rest alis))))
- (pprint-simple-code-list alis)))))
+ (if (and (next alis) (vector? (second alis)))
+ (pprint-logical-block
+ :prefix "(" :suffix ")"
+ (do
+ ((formatter-out "~w ~1I~@_") base-sym)
+ (pprint-binding-form (second alis))
+ ((formatter-out " ~_~{~w~^ ~_~}") (next (rest alis)))))
+ (pprint-simple-code-list alis))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--