Uninterned symbols are stored incorrectly

Create issue
Issue #101 resolved
Takashi Kato repo owner created an issue

This should not raise an error when the library is read from cache:

;; test-lib.scm
(library (test-lib)
    (export foo)
    (import (rnrs))

  (define-syntax define-inline
    (syntax-rules ()
      ((_ (?name ?arg ... . ?rest) ?form0 ?form ...)
       (define-syntax ?name
         (syntax-rules ()
           ((_ ?arg ... . ?rest)
            (begin ?form0 ?form ...)))))))

  (define-syntax define-foo
    (lambda (x)
      (syntax-case x ()
        ((_ foo)
         (with-syntax (((boo) (generate-temporaries #'(#f))))
           (write #'boo) (newline)
           #'(begin
               (define-inline (foo) (boo))
               (define (boo) 'buz)))))))
  (define-foo foo)
)
(import (test-lib))
(foo)

and got (from cache):

*error*
#<condition
  &undefined
  &who #:temp9
  &message unbound variable #:temp9 in library (test-lib)

>
stack trace:
  [1] #f
    src: (#:temp9)
  [2] load

Comments (3)

  1. Takashi Kato reporter

    The issue is a bit more compilcated than I expected. In short, we shouldn't use gensym for generate-temporaries. The generated symbols may be used on difference cache unit. For example, libA provides the code described on the issue and libB uses it. Then libB, in general, refers the uninterned symbol defined in libA. However if it's in cache then it won't be the same symbol.

    The resolution would, for now, only be generates unique enough interned symbols.

  2. Log in to comment