[plt-scheme] Illegal Use of #%plain-module-begin

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Jul 13 11:28:32 EDT 2006

At Thu, 13 Jul 2006 07:50:32 -0700, Casey Klein wrote:
> As an exercise, I tried to write a syntax transformation which wraps all
> constants in "begin" expressions which print them. This was my first
> attempt:
>    (define (annotate1 stx)
>     (syntax-case stx (#%datum)
>       [(#%datum . d) #'(begin (#%app write (#%datum . d)) (#%datum . d))]
>       [(first . rest) #`(#,(annotate1 #'first) . #,(annotate1 #'rest))]
>       [else #'else]))
> The result, printed as an s-exp using syntax-object->datum, looked 
> promising, but evaluation of the result produces the error 
> "#%plain-module-begin: illegal use (not a module body)". Manually 
> expanding the result, i.e. (expand (annotate1 src)), also produces this 
> error.

It's a bug. The `module' form is looking for `#%plain-module-begin',
but at one point it checks for a pair when it should check for a syntax

This is now fixed in SVN.


Posted on the users mailing list.