[racket-dev] modules with both 'test' and 'main' submodules: looks like a Dr bug?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Apr 26 23:48:54 EDT 2012

I've pushed a repair.

At Thu, 26 Apr 2012 21:09:50 -0500, Robby Findler wrote:
> And, in case this wasn't already obvious to those in the know, it
> appears that if you compile foo.rkt and then run "racket bar.rkt", you
> get the error as well. So probably something to do with something that
> happens when bytecode is unmarshalled, maybe?
> 
> (Thanks to Matthew for pointing this out.)
> 
> Robby
> 
> On Thu, Apr 26, 2012 at 8:25 PM, Robby Findler
> <robby at eecs.northwestern.edu> wrote:
> > If you run "raco make bar.rkt" you see the same error (and DrRacket is
> > doing that for you automatically). So probably the bug lies there if
> > anyone wants to investigate further.
> >
> > Robby
> >
> > On Thu, Apr 26, 2012 at 3:54 PM, John Clements
> > <clements at brinckerhoff.org> wrote:
> >> I'm seeing an inconsistency in the behavior of submodules that looks like a
> >> bug in DrRacket (as opposed to Racket).
> >>
> >> First, though, it looks like running a module in DrRacket runs *both* the
> >> main and test submodules, if they both exist. I don't think this behavior is
> >> documented; I see this text:
> >>
> >> "When a module is provided as a program name to the racket executable or run
> >> directly within DrRacket, if the module has a main submodule, the main
> >> submodule is run after its enclosing module."
> >>
> >> … but no similar mention of 'test'. So I'm guessing that's just a doc bug?
> >>
> >> The bigger issue, though, arises when I have a file containing both 'test'
> >> and 'main' submodules. It appears to me that I can't require the 'main'
> >> module externally when the modules are stored in separate files, but that I
> >> can when e.g. using #lang racket/load.
> >>
> >> So, this program:
> >>
> >> #lang racket/load
> >>
> >> (module foo racket
> >> (define (g) (printf "abc\n"))
> >> (define (h) (printf "def\n"))
> >>
> >> (module+ test
> >>   (g))
> >>
> >> (module+ main
> >>   (h))
> >> )
> >>
> >> (module bar racket
> >>   (require (submod 'foo main)))
> >>
> >> (require 'bar)
> >>
> >> … produces output "def", as I'd expect, but splitting it into two files:
> >>
> >> foo.rkt:
> >>
> >> #lang racket
> >>
> >> (define (g) (printf "abc\n"))
> >> (define (h) (printf "def\n"))
> >>
> >> (module+ test
> >>   (g))
> >>
> >> (module+ main
> >>   (h))
> >>
> >>
> >> bar.rkt:
> >>
> >> #lang racket
> >>
> >> (require (submod "foo.rkt" main))
> >>
> >>
> >>
> >> … and running "bar.rkt"  *in DrRacket* produces this message:
> >>
> >> require: unknown module: (submod "/private/tmp/foo.rkt" main)
> >>
> >>
> >> Running it from the command line, though, does what I'd expect:
> >>
> >> pcp069222pcs:/tmp clements$ racket ./bar.rkt
> >> def
> >>
> >>
> >>
> >> So it looks like DrRacket's not doing quite the right thing here.
> >>
> >> Apologies if this has been fixed since  5.3.0.2--2012-04-20(873c1bc/g) [3m].
> >>
> >> John
> >>
> >>
> >> _________________________
> >>  Racket Developers list:
> >>  http://lists.racket-lang.org/dev
> >>
> 
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev


Posted on the dev mailing list.