7.1 Unbound identifier in transformer environment
compile: unbound identifier in transformer environment (and no #%app syntax transformer is bound) in: syntax-case
compile: bad syntax; function application is not allowed, because no #%app syntax transformer is bound in: (syntax-case ___)
Usually, this means that you forgot to require scheme/base for-syntax. The scheme/base language does not provide a transformer-environment (aka for-syntax, phase 1) binding for syntax-case (or lambda, or anything else except for syntax-rules). So when the compiler encounters (syntax-case __), since it doesn’t find a phase-1 binding for syntax-case, it figures that the expression must be a function call instead. Then it looks for a binding of #%app, fails to find it, and reports that error.
(module m scheme/base |
(define-syntax (my-macro stx) |
(syntax-case stx () |
__))) |
(module m scheme/base |
(require (for-syntax scheme/base)) |
(define-syntax (my-macro stx) |
(syntax-case stx () |
__))) |
(module m scheme |
(define-syntax (my-macro stx) |
(syntax-case stx () |
__))) |
If the expression the error refers to doesn’t look like the body of a macro or static info expression (see Static Information), then continue to the next section.
7.1.1 Alternative causes
Another way to get this error is to neglect to require scheme/base for-template in a code generator module (see Code Generators). The macro expander goes through the same process as above, but at a different phase.