justinethier/husk-scheme

Error during macro expansion when referencing another non-exported variable from library

SaitoAtsushi opened this issue · 1 comments

This is similar to #162

(define-library (foo)
  (export bar)
  (import (scheme base))
  (begin 
    (define (baz) #f)
    (define-syntax bar
      (syntax-rules ()
        ((_) (baz))))
    ))
(import (scheme base)
        (foo))
(bar)
$ huski test.scm
Getting an unbound variable: baz

Thanks for the bug report.

Well, the macro transforms the expression into baz and then that identifier is not found. It seems it should have been, though, based on r7rs:

If a macro transformer inserts a free reference to an
identifier, the reference refers to the binding that was
visible where the transformer was specified, regardless
of any local bindings that surround the use of the
macro.