~ chicken-core (chicken-5) 159611d58b949fa4763aa9c2cbb27dfed931d074


commit 159611d58b949fa4763aa9c2cbb27dfed931d074
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Fri Oct 21 02:52:53 2011 +0200
Commit:     Peter Bex <peter.bex@xs4all.nl>
CommitDate: Fri Oct 21 14:16:55 2011 +0200

    handle macro-aliases when resolving declared identifier, making sure things are done right inside modules.
    
    Signed-off-by: Peter Bex <peter.bex@xs4all.nl>

diff --git a/expand.scm b/expand.scm
index 87cd8a2b..df379711 100644
--- a/expand.scm
+++ b/expand.scm
@@ -136,13 +136,16 @@
 ;;; resolve symbol to global name
 
 (define (##sys#globalize sym se)
-  (if (symbol? sym)
-      (let loop ((se se))			; ignores syntax bindings
-	(cond ((null? se)
-	       (##sys#alias-global-hook sym #f #f)) ;XXX could hint at decl (3rd arg)
-	      ((and (eq? sym (caar se)) (symbol? (cdar se))) (cdar se))
-	      (else (loop (cdr se)))))
-      sym))
+  (let loop1 ((sym sym))
+    (cond ((not (symbol? sym)) sym)
+	  ((getp sym '##core#macro-alias) =>
+	   (lambda (a) (if (symbol? a) (loop1 a) sym)))
+	  (else
+	   (let loop ((se se))		; ignores syntax bindings
+	     (cond ((null? se)
+		    (##sys#alias-global-hook sym #t #f)) ;XXX could hint at decl (3rd arg)
+		   ((and (eq? sym (caar se)) (symbol? (cdar se))) (cdar se))
+		   (else (loop (cdr se)))))))))
 
 
 ;;; Macro handling
Trap