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 27632763 (core/assert (core/= (core/first quoted) 'quote)
27642764 " Argument to macroexpand-1 must be quoted" )
27652765 (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)))
27672769
27682770(core/defmacro macroexpand
27692771 " Repeatedly calls macroexpand-1 on form until it no longer
27742776 " Argument to macroexpand must be quoted" )
27752777 (core/let [form (second quoted)
27762778 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)))
27812785
27822786(core/defn- multi-arity-fn? [fdecl]
27832787 (core/< 1 (count fdecl)))
Original file line number Diff line number Diff line change 1313
1414(deftest test-macros
1515 (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