>From 72d5564a795aca3d31b15cd10e59d592d995ac5a Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Sat, 21 Apr 2012 20:18:19 +0200 Subject: [PATCH] Always add default core macros to syntax env in internal compiler-syntax so that even when the user doesn't import scheme the macros will expand correctly --- compiler-syntax.scm | 9 +++++---- tests/scrutiny.expected | 6 +++--- tests/syntax-tests.scm | 6 ++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/compiler-syntax.scm b/compiler-syntax.scm index 85aae77..65a80db 100644 --- a/compiler-syntax.scm +++ b/compiler-syntax.scm @@ -46,7 +46,7 @@ (let ((t (cons (##sys#ensure-transformer (##sys#er-transformer transformer) (car names)) - se))) + (append se ##sys#default-macro-environment)))) (for-each (lambda (name) (##sys#put! name '##compiler#compiler-syntax t) ) @@ -66,6 +66,7 @@ (%loop (r 'for-each-loop)) (%proc (gensym)) (%begin (r 'begin)) + (%quote (r 'quote)) (%and (r 'and)) (%pair? (r 'pair?)) (%lambda (r 'lambda)) @@ -76,7 +77,7 @@ `(,%let ((,%proc ,(cadr x)) ,@(map list vars lsts)) ,@(map (lambda (var) - `(##core#check (##sys#check-list ,var 'for-each))) + `(##core#check (##sys#check-list ,var (,%quote for-each)))) vars) (,%let ,%loop ,(map list vars vars) (,%if (,%and ,@(map (lambda (v) `(,%pair? ,v)) vars)) @@ -89,7 +90,7 @@ x))) (define-internal-compiler-syntax ((map ##sys#map #%map) x r c) - (pair?) + (pair? cons) (let ((%let (r 'let)) (%if (r 'if)) (%loop (r 'map-loop)) @@ -113,7 +114,7 @@ (,%proc ,(cadr x)) ,@(map list vars lsts)) ,@(map (lambda (var) - `(##core#check (##sys#check-list ,var 'map))) + `(##core#check (##sys#check-list ,var (,%quote map)))) vars) (,%let ,%loop ,(map list vars vars) (,%if (,%and ,@(map (lambda (v) `(,%pair? ,v)) vars)) diff --git a/tests/scrutiny.expected b/tests/scrutiny.expected index 31eeb2b..f4200af 100644 --- a/tests/scrutiny.expected +++ b/tests/scrutiny.expected @@ -37,7 +37,7 @@ Warning: at toplevel: (scrutiny-tests.scm:28) in procedure call to `+', expected argument #2 of type `number', but was given an argument of type `symbol' Warning: at toplevel: - assignment of value of type `fixnum' to toplevel variable `car' does not match declared type `(forall (a123) (procedure car ((pair a123 *)) a123))' + assignment of value of type `fixnum' to toplevel variable `car' does not match declared type `(forall (a124) (procedure car ((pair a124 *)) a124))' Warning: at toplevel: expected in `let' binding of `g8' a single result, but were given 2 results @@ -47,9 +47,9 @@ Warning: at toplevel: Note: in toplevel procedure `foo': expected value of type boolean in conditional but were given a value of type - `(procedure bar29 () *)' which is always true: + `(procedure bar30 () *)' which is always true: -(if bar29 3 (##core#undefined)) +(if bar30 3 (##core#undefined)) Warning: in toplevel procedure `foo2': (scrutiny-tests.scm:57) in procedure call to `string-append', expected argument #1 of type `string', but was given an argument of type `number' diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm index c1a2fa8..cad0d39 100644 --- a/tests/syntax-tests.scm +++ b/tests/syntax-tests.scm @@ -974,3 +974,9 @@ take (import (prefix chicken c/) (prefix scheme s/)) (c/case-lambda ((a) a)) (c/ensure s/even? 2)) + + +;; #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 -- 1.7.9.1