cisco / ChezScheme

Chez Scheme
Apache License 2.0
6.97k stars 984 forks source link

Out of scope syntax-parameterize and local variables #798

Closed jcubic closed 8 months ago

jcubic commented 8 months ago

I'm implementing syntax-parameterize in my Scheme interpreter and testing the implementation with Chez Scheme and found a bug in Chez. Here is a use case:

(define-syntax foo
  (syntax-rules ()
    ((_ body ...)
     (begin
       (syntax-parameterize
        ((it (syntax-rules ()
               ((_) "hello world")))))
       body ...))))

Where the body is outside of syntax-parameterize.

Both expressions:

(let ((it 10))
  (print (foo (it))))

(foo (let ((it 10))
       (print it)))

throws:

Exception: variable it is not bound

But it should throw an error about 10 not being a function. This should work:

(let ((it 10))
  (print (foo it)))

and display 10 but it gives an exception.

The above works in Guile.

jcubic commented 8 months ago

Sorry my bad, I was confused about error messages because it didn't give an error about unbound syntax-parameterize only about (it) because it tried to execute it from this expression:

((it (syntax-rules ()