File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 2763
2763
(core/assert (core/= (core/first quoted) 'quote)
2764
2764
" Argument to macroexpand-1 must be quoted" )
2765
2765
(core/let [form (second quoted)]
2766
- `(quote ~(ana/macroexpand-1 &env form))))
2766
+ (if (seq? form)
2767
+ `(quote ~(ana/macroexpand-1 &env form))
2768
+ form)))
2767
2769
2768
2770
(core/defmacro macroexpand
2769
2771
" Repeatedly calls macroexpand-1 on form until it no longer
2774
2776
" Argument to macroexpand must be quoted" )
2775
2777
(core/let [form (second quoted)
2776
2778
env &env]
2777
- (core/loop [form form form' (ana/macroexpand-1 env form)]
2778
- (core/if-not (core/identical? form form')
2779
- (recur form' (ana/macroexpand-1 env form'))
2780
- `(quote ~form')))))
2779
+ (if (seq? form)
2780
+ (core/loop [form form form' (ana/macroexpand-1 env form)]
2781
+ (core/if-not (core/identical? form form')
2782
+ (recur form' (ana/macroexpand-1 env form'))
2783
+ `(quote ~form')))
2784
+ form)))
2781
2785
2782
2786
(core/defn- multi-arity-fn? [fdecl]
2783
2787
(core/< 1 (count fdecl)))
Original file line number Diff line number Diff line change 13
13
14
14
(deftest test-macros
15
15
(is (= (== 1 1 ) 2 )))
16
+
17
+ (deftest macroexpansion
18
+ (is (= 1 (macroexpand-1 '1 )))
19
+ (is (= '(if true (do 1 )) (macroexpand-1 '(when true 1 ))))
20
+ (is (= 1 (macroexpand '1 )))
21
+ (is (= '(if true (do 1 )) (macroexpand '(when true 1 )))))
You can’t perform that action at this time.
0 commit comments