Permalink
Browse files

Let "#(%&)" read correctly, fixes #TRDR-8

  • Loading branch information...
1 parent 8863907 commit 8f48f83a5ad0dbd7f4c8e612c4ab764d418feb93 @Bronsa Bronsa committed Aug 14, 2013
Showing with 11 additions and 11 deletions.
  1. +9 −10 src/main/clojure/clojure/tools/reader.clj
  2. +2 −1 src/test/clojure/clojure/tools/reader_test.clj
@@ -330,16 +330,15 @@
rargs (rseq arg-env)
args (if rargs
(let [higharg (key (first rargs))]
- (if (pos? higharg)
- (let [args (loop [i 1 args (transient [])]
- (if (> i higharg)
- (persistent! args)
- (recur (inc i) (conj! args (or (get arg-env i)
- (garg i))))))
- args (if (arg-env -1)
- (conj args '& (arg-env -1))
- args)]
- args)))
+ (let [args (loop [i 1 args (transient [])]
+ (if (> i higharg)
+ (persistent! args)
+ (recur (inc i) (conj! args (or (get arg-env i)
+ (garg i))))))
+ args (if (arg-env -1)
+ (conj args '& (arg-env -1))
+ args)]
+ args))
[])]
(list 'fn* args form))))
@@ -46,7 +46,8 @@
(is (= '(fn* [] (foo bar baz)) (read-string "#(foo bar baz)"))))
(deftest read-arg
- (is (= 14 ((eval (read-string "#(apply + % %1 %3 %&)")) 1 2 3 4 5))))
+ (is (= 14 ((eval (read-string "#(apply + % %1 %3 %&)")) 1 2 3 4 5)))
+ (is (= 4 ((eval (read-string "#(last %&)")) 1 2 3 4))))
(deftest read-eval
(is (= 3 (read-string "#=(+ 1 2)"))))

0 comments on commit 8f48f83

Please sign in to comment.