Ticket #219: 0001-Attempt-to-fix-219-where-renamed-reexports-are-not-c.patch

File 0001-Attempt-to-fix-219-where-renamed-reexports-are-not-c.patch, 4.1 KB (added by felix winkelmann, 10 years ago)
  • distribution/manifest

    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 
    158158tests/reexport-m2.scm
    159159tests/reexport-m3.scm
    160160tests/reexport-m4.scm
     161tests/reexport-m5.scm
     162tests/reexport-m6.scm
    161163tests/reexport-tests.scm
    162164tests/reexport-tests-2.scm
    163165tests/ec.scm
  • modules.scm

    diff --git a/modules.scm b/modules.scm
    index 1fe67d8..913d448 100644
    a b  
    375375    (##sys#mark-imported-symbols iexps)
    376376    (for-each
    377377     (lambda (sexp)
    378        (set-car! (cdr sexp) senv))
     378       (set-car! (cdr sexp) (merge-se (or (cadr sexp) '()) senv)))
    379379     sexps)
    380380    (for-each
    381381     (lambda (iexp)
    382382       (when (pair? (cdr iexp))
    383          (set-car! (cdr iexp) senv)))
     383         (set-car! (cdr iexp) (merge-se (or (cadr iexp) '()) senv))))
    384384     iexps)
    385385    (for-each
    386386     (lambda (nexp)
    387        (set-car! (cdr nexp) senv))
     387       (set-car! (cdr nexp) (merge-se (or (cadr nexp) '()) senv)))
    388388     nexps)
    389389    (set! ##sys#module-table (cons (cons name mod) ##sys#module-table))
    390390    mod))
  • tests/reexport-m3.scm

    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)
    12(module
    23 reexport-m3
    34 ((foo bar))
  • tests/reexport-m4.scm

    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)
    12(module
    23 reexport-m4
    34 (baz)
  • new file tests/reexport-m5.scm

    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)))))
  • new file tests/reexport-m6.scm

    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:)))
  • tests/reexport-tests-2.scm

    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
    12(use reexport-m4)
    23(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)
  • tests/runtests.sh

    diff --git a/tests/runtests.sh b/tests/runtests.sh
    index f902a98..1434eb7 100755
    a b $compile reexport-m2.scm 
    210210./a.out
    211211$compile_s reexport-m3.scm -J
    212212$compile_s reexport-m4.scm -J
     213$compile_s reexport-m5.scm -J
     214$compile_s reexport-m6.scm -J
    213215$compile reexport-tests-2.scm
    214216./a.out
    215217