<div dir="ltr"><div><div>Thanks, Matthew.<br><br></div>I fixed it by not expanding the module* form in the local-expand, <br>i.e. I used (list #'module*) as the third argument to local-expand.<br></div><div><br></div>Cheers,<br>Marco<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 22, 2014 at 4:38 PM, Matthew Flatt <span dir="ltr"><<a href="mailto:mflatt@cs.utah.edu" target="_blank">mflatt@cs.utah.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think this may be a problem in macro expansion with submodules.<br>
<br>
The `#%module-begin` from `racket/base` adds a submodule declaration<br>
for `configure-runtime` when it doesn't see an existing submodule<br>
declaration for `configure-runtime` --- but it looks for an existing<br>
declaration as an immediate one, before macro-expanding the module<br>
body.<br>
<br>
In your code, the `mute` wrapper hides the declaration of<br>
`configure-runtime`, so a conflicting one gets added. The tricky part<br>
is that this happens the second time that the `test` submodule is<br>
expanded:<br>
<br>
 * The overall module's body is forced via `local-expand`.<br>
<br>
 * As a part of that local expansion, the `test` submodule is expanded'<br>
   its expansion includes a declaration of a `configure-runtime`<br>
   submodule.<br>
<br>
 * The overall module's expanded body is wrapped back in<br>
   `#%module-begin`, which will re-expand all of the content, including<br>
   the `test` submodule.<br>
<br>
 * The `test` submodule this second time around has a `#%module-begin`<br>
   that is supposed to be bound to `#%plain-module-begin`, but it ends<br>
   up being captured[*] by `#%module-begin` from "bootstrap-lang.rkt",<br>
   so that the submodule's body is again local-expanded and again send<br>
   to `#%module-begin` from `racket/base` with a `mute` wrapper around<br>
   the `configure-runtime` sub-submodule.<br>
<br>
The [*] step seems wrong to me. I think this may be an example of a<br>
problem deep in the macro expander, and solving that is my next<br>
project.<br>
<br>
<br>
Since the repair (assuming that I have correctly diagnosed the cause)<br>
may be a while, do you have a workaround already? The macro name `mute`<br>
suggests that you may want to suppress the printing of expression<br>
results at the top-level of a module, and that might be as easy as<br>
expanding `#%module-begin` to `#%plain-module-begin`. Or maybe<br>
`syntax/wrap-modbeg` can help, or maybe the strategy used by<br>
`syntax/wrap-modbeg` would work better for your macro.<br>
<div><div class="h5"><br>
<br>
At Thu, 21 Aug 2014 17:22:29 +0100, Marco Monteiro wrote:<br>
> Hello!<br>
><br>
> I'm using Racket 6.1<br>
><br>
> I'm trying to understand this error. I'm using submodules in a language I<br>
> defined. The language file is here:<br>
><br>
> <a href="http://pastebin.com/7RiHHRmi" target="_blank">http://pastebin.com/7RiHHRmi</a><br>
><br>
> Notice the commented out line 28.<br>
><br>
> I use that language in the following code<br>
><br>
> <a href="http://pastebin.com/Qa6RD9wF" target="_blank">http://pastebin.com/Qa6RD9wF</a><br>
><br>
> raco expanding this last file fails with<br>
><br>
> module: duplicate submodule definition<br>
>   at: configure-runtime<br>
>   in: module<br>
>   context...:<br>
>    /usr/share/racket/pkgs/compiler-lib/compiler/commands/expand.rkt:29:11:<br>
> loop<br>
>    /usr/share/racket/pkgs/compiler-lib/compiler/commands/expand.rkt:<br>
> [running body]<br>
>    /usr/share/racket/collects/raco/raco.rkt: [running body]<br>
>    /usr/share/racket/collects/raco/main.rkt: [running body]<br>
><br>
> If I uncomment line 28 it no longer fails. If I use (module ...) instead of<br>
> (module* ...) it no longer fails independently of line 28 being commented<br>
> out or not.<br>
><br>
> Trying to macro expand that in drracket gives me "Internal error: car:<br>
> contract violation ." error.<br>
><br>
> What is happending here?<br>
><br>
> Thanks,<br>
> Marco<br>
</div></div>> ____________________<br>
>   Racket Users list:<br>
>   <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div><br></div>