husk-scheme icon indicating copy to clipboard operation
husk-scheme copied to clipboard

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

Open SaitoAtsushi opened this issue 10 years ago • 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

SaitoAtsushi avatar Mar 02 '16 10:03 SaitoAtsushi

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.

justinethier avatar Mar 02 '16 15:03 justinethier