Opened 10 years ago

Closed 2 years ago

Last modified 2 years ago

#1295 closed defect (fixed)

module-environment use with macros

Reported by: Caolan McMahon Owned by:
Priority: major Milestone: 5.4
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 (7)

comment:1 by sjamaan, 9 years ago

Estimated difficulty: hard

comment:2 by sjamaan, 9 years ago

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

comment:3 by Caolan McMahon, 9 years ago

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)))))

comment:4 by felix winkelmann, 2 years ago

Milestone: someday6.0.0

comment:5 by sjamaan, 2 years ago

Fixed with fe4e2db7b36c46028f9dadcda19010d1f684c406

comment:6 by sjamaan, 2 years ago

Resolution: fixed
Status: newclosed

comment:7 by sjamaan, 2 years ago

Milestone: 6.0.05.4
Note: See TracTickets for help on using tickets.