>From 993db03b3aeffd733624c3b367da73f29060db06 Mon Sep 17 00:00:00 2001 From: felix Date: Sat, 22 Feb 2014 14:55:25 +0100 Subject: [PATCH] Attempt to fix #219 where renamed reexports are not correctly resolved. This follows a hint given by sjamaan, in that "##sys#register-compiled-module" clobbers the syntactic environments (SEs) of exported syntactic definitions with new complete SE built from all imports. This patch keeps the old SEs of each exported syntactic binding my merging instead of overwriting. This appears to fix the bug and all tests run ok for me, so far. Signed-off-by: Peter Bex --- distribution/manifest | 2 ++ modules.scm | 6 +++--- tests/reexport-m3.scm | 1 + tests/reexport-m4.scm | 1 + tests/reexport-m5.scm | 8 ++++++++ tests/reexport-m6.scm | 2 ++ tests/reexport-tests-2.scm | 6 ++++++ tests/runtests.bat | 13 +++++++++++++ tests/runtests.sh | 2 ++ 9 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 tests/reexport-m5.scm create mode 100644 tests/reexport-m6.scm diff --git a/distribution/manifest b/distribution/manifest index e9e5fcb..791389e 100644 --- a/distribution/manifest +++ b/distribution/manifest @@ -158,6 +158,8 @@ tests/reexport-m1.scm tests/reexport-m2.scm tests/reexport-m3.scm tests/reexport-m4.scm +tests/reexport-m5.scm +tests/reexport-m6.scm tests/reexport-tests.scm tests/reexport-tests-2.scm tests/ec.scm diff --git a/modules.scm b/modules.scm index 1fe67d8..913d448 100644 --- a/modules.scm +++ b/modules.scm @@ -375,16 +375,16 @@ (##sys#mark-imported-symbols iexps) (for-each (lambda (sexp) - (set-car! (cdr sexp) senv)) + (set-car! (cdr sexp) (merge-se (or (cadr sexp) '()) senv))) sexps) (for-each (lambda (iexp) (when (pair? (cdr iexp)) - (set-car! (cdr iexp) senv))) + (set-car! (cdr iexp) (merge-se (or (cadr iexp) '()) senv)))) iexps) (for-each (lambda (nexp) - (set-car! (cdr nexp) senv)) + (set-car! (cdr nexp) (merge-se (or (cadr nexp) '()) senv))) nexps) (set! ##sys#module-table (cons (cons name mod) ##sys#module-table)) mod)) diff --git a/tests/reexport-m3.scm b/tests/reexport-m3.scm index 202e6b3..4a54802 100644 --- a/tests/reexport-m3.scm +++ b/tests/reexport-m3.scm @@ -1,3 +1,4 @@ +;;; export syntax with implicit value export (reexport-test-2.scm) (module reexport-m3 ((foo bar)) diff --git a/tests/reexport-m4.scm b/tests/reexport-m4.scm index c81287b..4ccea9e 100644 --- a/tests/reexport-m4.scm +++ b/tests/reexport-m4.scm @@ -1,3 +1,4 @@ +;;; export syntax that refers to reexported syntax (reexport-test-2.scm) (module reexport-m4 (baz) diff --git a/tests/reexport-m5.scm b/tests/reexport-m5.scm new file mode 100644 index 0000000..3e0a92f --- /dev/null +++ b/tests/reexport-m5.scm @@ -0,0 +1,8 @@ +;;; export syntax, one definition refering to another +; used for testing reexport wth renaming (reexport-test-2.scm) +(module reexport-m5 * +(import scheme) +(define-syntax s1 + (syntax-rules () ((_) (s2)))) +(define-syntax s2 + (syntax-rules () ((_) (display 1))))) diff --git a/tests/reexport-m6.scm b/tests/reexport-m6.scm new file mode 100644 index 0000000..803b9b8 --- /dev/null +++ b/tests/reexport-m6.scm @@ -0,0 +1,2 @@ +(module reexport-m6 () +(reexport (prefix reexport-m5 f:))) diff --git a/tests/reexport-tests-2.scm b/tests/reexport-tests-2.scm index 35ef76d..dadab72 100644 --- a/tests/reexport-tests-2.scm +++ b/tests/reexport-tests-2.scm @@ -1,2 +1,8 @@ +;;; export of syntax referring to reexported syntax binding (use reexport-m4) (print (baz)) + +;;; reexport of renamed syntax +(import reexport-m6) +(f:s1) ; expands to s2, which is reexported and refers to "s2", which is also visible in this context as "f:s2" +(f:s2) diff --git a/tests/runtests.bat b/tests/runtests.bat index c503f15..120526c 100644 --- a/tests/runtests.bat +++ b/tests/runtests.bat @@ -209,6 +209,19 @@ if errorlevel 1 exit /b 1 if errorlevel 1 exit /b 1 a.out if errorlevel 1 exit /b 1 +%compile_s% reexport-m3.scm -J +if errorlevel 1 exit /b 1 +%compile_s% reexport-m4.scm -J +if errorlevel 1 exit /b 1 +%compile_s% reexport-m5.scm -J +if errorlevel 1 exit /b 1 +%compile_s% reexport-m6.scm -J +if errorlevel 1 exit /b 1 +%compile% reexport-tests-2.scm +if errorlevel 1 exit /b 1 +a.out +if errorlevel 1 exit /b 1 + echo ======================================== functor tests ... %interpret% -bnq simple-functors-test.scm diff --git a/tests/runtests.sh b/tests/runtests.sh index f902a98..1434eb7 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -210,6 +210,8 @@ $compile reexport-m2.scm ./a.out $compile_s reexport-m3.scm -J $compile_s reexport-m4.scm -J +$compile_s reexport-m5.scm -J +$compile_s reexport-m6.scm -J $compile reexport-tests-2.scm ./a.out -- 1.7.10.4