~ chicken-core (chicken-5) f0770c330de183017c0d4a6b17ab135e6f42af67


commit f0770c330de183017c0d4a6b17ab135e6f42af67
Author:     LemonBoy <thatlemon@gmail.com>
AuthorDate: Mon May 15 20:19:37 2017 +0200
Commit:     Peter Bex <peter@more-magic.net>
CommitDate: Sat May 27 15:19:48 2017 +0200

    Keep the module module-defined-syntax-list updated
    
    When a macro is shadowed via a set! it is also removed from the
    macro-environment but not from the current module's export list. This
    leads to a compile-time error during the module finalization phase.
    
    Signed-off-by: Evan Hanson <evhan@foldling.org>
    Signed-off-by: Peter Bex <peter@more-magic.net>

diff --git a/core.scm b/core.scm
index 7c8a2f45..e73d207c 100644
--- a/core.scm
+++ b/core.scm
@@ -1115,7 +1115,9 @@
 					  (warning
 					   (sprintf "~aassignment to syntax `~S'"
 					    (if ln (sprintf "(~a) - " ln) "") var0))
-					  (when undefine-shadowed-macros (##sys#undefine-macro! var0)))
+					  (when undefine-shadowed-macros
+					    (##sys#undefine-macro! var0)
+					    (##sys#unregister-syntax-export var0 (##sys#current-module))))
 					 ((assq var0 (##sys#current-environment))
 					  (warning
 					   (sprintf "~aassignment to imported value binding `~S'"
diff --git a/modules.scm b/modules.scm
index a5680b2a..4470a1b6 100644
--- a/modules.scm
+++ b/modules.scm
@@ -224,6 +224,12 @@
        mod
        (cons (cons sym val) (module-defined-syntax-list mod))))))
 
+(define (##sys#unregister-syntax-export sym mod)
+  (when mod
+    (set-module-defined-syntax-list!
+     mod
+     (delete sym (module-defined-syntax-list mod) (lambda (x y) (eq? x (car y)))))))
+
 (define (register-undefined sym mod where)
   (when mod
     (let ((ul (module-undefined-list mod)))
Trap