[racket-dev] weird "module: identifier is already imported" error

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Jun 21 17:34:36 EDT 2012

Christos, time to file a bug report (with code snippets). -- Matthias


On Jun 21, 2012, at 4:41 PM, Ryan Culpepper wrote:

> I can reproduce this error in DrRacket (both with and without debuggging enabled) but not in racket. So maybe DrRacket is doing something odd, or perhaps there's a bug in module->namespace or something like that.
> 
> Ryan
> 
> 
> On 06/21/2012 01:52 PM, Christos Dimoulas wrote:
>> Hi,
>> 
>> I ran into an error that I can't explain. Do you have any hints about
>> what is going on or any suggestions on how to fix it?
>> 
>> In the following code, macros provides alternative forms for require and
>> provide, dubbed accept and provide/dispute. They are doing the same job
>> as provide and require except that they create a fresh identifier to add
>> a little bit of indirection. The first client defines foo and provides
>> it with provide/dispute. The other clients just use accept and
>> provide/dispute to pass along foo.
>> 
>> When I ran the code I get ''module: identifier is already imported in:
>> foo2''.
>> 
>> Thanks.
>> 
>> #lang racket
>> 
>> (module macros racket
>> 
>> (provide accept provide/dispute)
>> 
>> (define-syntax (accept stx)
>> (syntax-case stx ()
>> [(_ spec id)
>> (with-syntax ([(new-id) (generate-temporaries #'(id))])
>> #`(begin
>> (require (only-in spec [id new-id]))
>> (define id new-id)))]))
>> 
>> (define-syntax (provide/dispute stx)
>> (syntax-case stx ()
>> [(_ id)
>> (with-syntax ([(new-id) (generate-temporaries #'(id))])
>> #`(begin
>> (define new-id id)
>> (provide (rename-out [new-id id]))))])))
>> 
>> (module client1 racket
>> 
>> (require (submod ".." macros))
>> 
>> (define (foo x) x)
>> 
>> (provide/dispute foo))
>> 
>> (module client2 racket
>> 
>> (require (submod ".." macros))
>> 
>> (accept (submod ".." client1) foo)
>> 
>> (provide/dispute foo))
>> 
>> (module client3 racket
>> 
>> (require (submod ".." macros))
>> 
>> (accept (submod ".." client2) foo)
>> 
>> (provide/dispute foo))
>> 
>> 
>> _________________________
>> Racket Developers list:
>> http://lists.racket-lang.org/dev
> _________________________
> Racket Developers list:
> http://lists.racket-lang.org/dev



Posted on the dev mailing list.