From d93721f94f4d91c2a0902b67efdd57896ad08a2d Mon Sep 17 00:00:00 2001
From: felix <felix@call-with-current-continuation.org>
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.
---
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.sh | 2 ++
8 files changed, 25 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
|
b
|
tests/reexport-m1.scm |
158 | 158 | tests/reexport-m2.scm |
159 | 159 | tests/reexport-m3.scm |
160 | 160 | tests/reexport-m4.scm |
| 161 | tests/reexport-m5.scm |
| 162 | tests/reexport-m6.scm |
161 | 163 | tests/reexport-tests.scm |
162 | 164 | tests/reexport-tests-2.scm |
163 | 165 | tests/ec.scm |
diff --git a/modules.scm b/modules.scm
index 1fe67d8..913d448 100644
a
|
b
|
|
375 | 375 | (##sys#mark-imported-symbols iexps) |
376 | 376 | (for-each |
377 | 377 | (lambda (sexp) |
378 | | (set-car! (cdr sexp) senv)) |
| 378 | (set-car! (cdr sexp) (merge-se (or (cadr sexp) '()) senv))) |
379 | 379 | sexps) |
380 | 380 | (for-each |
381 | 381 | (lambda (iexp) |
382 | 382 | (when (pair? (cdr iexp)) |
383 | | (set-car! (cdr iexp) senv))) |
| 383 | (set-car! (cdr iexp) (merge-se (or (cadr iexp) '()) senv)))) |
384 | 384 | iexps) |
385 | 385 | (for-each |
386 | 386 | (lambda (nexp) |
387 | | (set-car! (cdr nexp) senv)) |
| 387 | (set-car! (cdr nexp) (merge-se (or (cadr nexp) '()) senv))) |
388 | 388 | nexps) |
389 | 389 | (set! ##sys#module-table (cons (cons name mod) ##sys#module-table)) |
390 | 390 | mod)) |
diff --git a/tests/reexport-m3.scm b/tests/reexport-m3.scm
index 202e6b3..4a54802 100644
a
|
b
|
|
| 1 | ;;; export syntax with implicit value export (reexport-test-2.scm) |
1 | 2 | (module |
2 | 3 | reexport-m3 |
3 | 4 | ((foo bar)) |
diff --git a/tests/reexport-m4.scm b/tests/reexport-m4.scm
index c81287b..4ccea9e 100644
a
|
b
|
|
| 1 | ;;; export syntax that refers to reexported syntax (reexport-test-2.scm) |
1 | 2 | (module |
2 | 3 | reexport-m4 |
3 | 4 | (baz) |
diff --git a/tests/reexport-m5.scm b/tests/reexport-m5.scm
new file mode 100644
index 0000000..8bdb435
-
|
+
|
|
| 1 | ;;; export syntax, one definition refering to another |
| 2 | ; used for testing reexport wth renaming (reexport-test-2.scm) |
| 3 | (module reexport-m5 * |
| 4 | (import scheme) |
| 5 | (define-syntax s1 |
| 6 | (syntax-rules () ((_) (s2)))) |
| 7 | (define-syntax s2 |
| 8 | (syntax-rules () ((_) (display 1))))) |
diff --git a/tests/reexport-m6.scm b/tests/reexport-m6.scm
new file mode 100644
index 0000000..803b9b8
-
|
+
|
|
| 1 | (module reexport-m6 () |
| 2 | (reexport (prefix reexport-m5 f:))) |
diff --git a/tests/reexport-tests-2.scm b/tests/reexport-tests-2.scm
index 35ef76d..dadab72 100644
a
|
b
|
|
| 1 | ;;; export of syntax referring to reexported syntax binding |
1 | 2 | (use reexport-m4) |
2 | 3 | (print (baz)) |
| 4 | |
| 5 | ;;; reexport of renamed syntax |
| 6 | (import reexport-m6) |
| 7 | (f:s1) ; expands to s2, which is reexported and refers to "s2", which is also visible in this context as "f:s2" |
| 8 | (f:s2) |
diff --git a/tests/runtests.sh b/tests/runtests.sh
index f902a98..1434eb7 100755
a
|
b
|
$compile reexport-m2.scm |
210 | 210 | ./a.out |
211 | 211 | $compile_s reexport-m3.scm -J |
212 | 212 | $compile_s reexport-m4.scm -J |
| 213 | $compile_s reexport-m5.scm -J |
| 214 | $compile_s reexport-m6.scm -J |
213 | 215 | $compile reexport-tests-2.scm |
214 | 216 | ./a.out |
215 | 217 | |