Konrad Hinsen <
google...@khinsen.fastmail.net> writes:
>> Does this make sense for some reason I don't understand? Is this a
>> bug? I can file an issue with the patch — unless this is really
>> intended behavior?
>
> It's a bug.
Oh, indeed, I was wrong. I've just validated it against CL.
(macrolet ((foo (x) `(1+ ,x)))
(flet ((foo (x) x))
(foo 1)))
;=> 1
> Patch welcome!
Here it is.
--8<---------------cut here---------------start------------->8---
From 7c481029d94e0af85cf6438d10fa6666f3f2d778 Mon Sep 17 00:00:00 2001
From: Tassilo Horn <
ts...@gnu.org>
Date: Mon, 26 Nov 2012 21:01:20 +0100
Subject: [PATCH] Don't apply macro expansion to protected forms
---
src/main/clojure/clojure/tools/macro.clj | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/main/clojure/clojure/tools/macro.clj b/src/main/clojure/clojure/tools/macro.clj
index 33e450d..be1bf43 100644
--- a/src/main/clojure/clojure/tools/macro.clj
+++ b/src/main/clojure/clojure/tools/macro.clj
@@ -69,10 +69,11 @@
(cond
(seq? form)
(let [f (first form)]
- (cond (contains? special-forms f) form
- (contains? macro-fns f) (apply (get macro-fns f) (rest form))
+ (cond (contains? special-forms f) form
+ (and (not (protected? f))
+ (contains? macro-fns f)) (apply (get macro-fns f) (rest form))
(symbol? f) (cond
- (protected? f) form
+ (protected? f) form
; macroexpand-1 fails if f names a class
(class? (ns-resolve *ns* f)) form
:else (let [exp (expand-symbol f)]
--
1.8.0
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo