~ chicken-core (chicken-5) bd1d0fc65ce824b1f71df9b6e220b98ff4fc6533


commit bd1d0fc65ce824b1f71df9b6e220b98ff4fc6533
Author:     Peter Bex <peter.bex@xs4all.nl>
AuthorDate: Sat May 19 17:46:36 2012 +0200
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Mon May 21 09:55:34 2012 +0200

    Do not allow closure compiler to access macros as first-class objects; this is not supported and not useful either. This fixes #852

diff --git a/eval.scm b/eval.scm
index 9f7a9cfd..10a9bec2 100644
--- a/eval.scm
+++ b/eval.scm
@@ -247,10 +247,11 @@
 	      ((symbol? x)
 	       (receive (i j) (lookup x e se)
 		 (cond ((not i)
-			(let ((var (if (not (assq x se))
-				       (and (not static)
-					    (##sys#alias-global-hook j #f cntr))
-				       (or (##sys#get j '##core#primitive) j))))
+			(let ((var (cond ((not (symbol? j)) x) ; syntax?
+                                         ((not (assq x se))
+                                          (and (not static)
+                                               (##sys#alias-global-hook j #f cntr)))
+                                         (else (or (##sys#get j '##core#primitive) j)))))
 			  (when (and ##sys#unbound-in-eval
 				     (or (not var)
 					 (not (##sys#symbol-has-toplevel-binding? var))))
diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm
index 98dddf35..833d1ed9 100644
--- a/tests/syntax-tests.scm
+++ b/tests/syntax-tests.scm
@@ -1030,4 +1030,15 @@ take
 ;; #816: compiler-syntax should obey hygiene in its rewrites
 (module foo ()
   (import (prefix (only scheme map lambda list) ~))
-  (~map (~lambda (y) y) (~list 1)))
\ No newline at end of file
+  (~map (~lambda (y) y) (~list 1)))
+
+;; #852: renamed macros should not be returned as first-class
+;;       objects in the interpreter
+(module renamed-macros (renamed-macro-not-firstclassed)
+  (import chicken scheme)
+  (define-syntax renamed-macro-not-firstclassed
+    (er-macro-transformer
+     (lambda (e r c)
+       `(,(r 'list) ,(r 'define))))))
+
+(f (eval '(begin (import renamed-macros) (renamed-macro-not-firstclassed))))
\ No newline at end of file
Trap