Opened 8 years ago

Closed 11 months ago

Last modified 11 months 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 Changed 8 years ago by sjamaan

Estimated difficulty: hard

comment:2 Changed 8 years ago by sjamaan

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

comment:3 Changed 8 years ago by Caolan McMahon

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 Changed 11 months ago by felix winkelmann

Milestone: someday6.0.0

comment:5 Changed 11 months ago by sjamaan

Fixed with fe4e2db7b36c46028f9dadcda19010d1f684c406

comment:6 Changed 11 months ago by sjamaan

Resolution: fixed
Status: newclosed

comment:7 Changed 11 months ago by sjamaan

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