Opened 18 months ago

Last modified 8 months ago

#1295 new defect

module-environment use with macros

Reported by: caolan Owned by:
Priority: major Milestone: someday
Component: core libraries Version: 4.11.0
Keywords: Cc:
Estimated difficulty: hard

Description

Given the following module example.scm:

(module example *

(import chicken scheme)

(define (add a b) (+ a b))

(define-syntax double
  (syntax-rules ()
    ((_ x) (add x x))))

)

Then, using it as an eval environment:

(load "./example.scm")
(import example)

(print (eval '(double 10) (module-environment 'example)))

I get:

Error: unbound variable: add43

Using the macro directly it appears to work:

(load "./example.scm")
(import example)

(print (double 10))

It now prints 20, as expected.

Is this a problem with module-environment, or am I using it incorrectly?

Change History (3)

comment:1 Changed 15 months ago by sjamaan

  • Estimated difficulty set to hard

comment:2 Changed 15 months ago by sjamaan

This looks like a bug, but I'll have to look closer when I have more time

comment:3 Changed 8 months ago by caolan

Just in case anyone else runs into this issue, I'm working around it by using er-macro-transformer instead of syntax-rules:

(define-syntax double
  (er-macro-transformer
    (lambda (exp rename compare)
      (list (rename 'add) (cadr exp) (cadr exp)))))
Note: See TracTickets for help on using tickets.