[racket] local-expand 'module-begin

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Sep 19 08:29:32 EDT 2013

I've pushed a repair for this bug. Ryan (thanks!) was exactly right
about the cause.

At Fri, 13 Sep 2013 00:21:07 +0200, Tero Hasu wrote:
> Ah, okay. Thanks Ryan.
> 
> So it looks like the exact same phase-2 x binding is being introduced
> twice, first during local-expand, and then during processing of the
> expanded code, which causes a conflict. (And that something is being
> done to prevent that for phase 0 and 1 bindings.) Fortunately this is
> the sort of problem that I'm unlikely to soon run into in practical
> code, I should think. Was just doing some testing.
> 
> I conclude that long as I avoid top-level phase 2+ bindings, and I
> guess beware of duplication of top-level phase 1+ side-effecting
> operations, I should be okay with this approach.
> 
> 
> On 12/09/13 22:16, Ryan Culpepper wrote:
> 
> > Note that the problem is not restricted to submodules, and it has
> > nothing to do with the fact that x is defined in two phases. The same
> > error is raised by this program:
> >
> > #lang racket/load
> >
> > (module le-lang racket
> >    (provide
> >     (except-out (all-from-out racket) #%module-begin)
> >     (rename-out [module-begin #%module-begin]))
> >
> >    (define-syntax (module-begin stx)
> >      (syntax-case stx ()
> >        ((_ . bs)
> >         (local-expand
> >          #'(#%module-begin . bs)
> >          'module-begin null)))))
> >
> > (module le-module 'le-lang
> >    (require (for-meta 2 racket/base))
> >    (define x 0)
> >    (begin-for-syntax
> >      (begin-for-syntax
> >        (define y 2))))
> >
> > I conjecture that maybe the problem is that the module's environment (or
> > renames?) is not being cleared/reset at all phases when 'local-expand'
> > returns, only phases 0 and 1. But in a brief search of the expander code
> > I wasn't able to confirm my guess.
> >
> > Ryan
> >
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.