This is certainly confusing.
The missing piece of the puzzle has to do with expansion in an
immediate module body. In that context, the macro expander adds the
module's "inside-edge" scope (unshifted) to the result of any macro
expansion. So, the expander is adding back the inside-edge scope that
is effectively removed by phase shifting in `bind-test0`.
If you use `bind-test0` in a more nested position, then it behaves the
way you expected:
(let ()
(bind-test0 5))
The addition of an inside-edge scope by the expander is the same as for
an internal definition context. See sections 1.2.3.8 and 1.2.3.9 in the
reference:
https://docs.racket-lang.org/reference/syntax-model.html?q=internal%20definition#%28part._intdef-body%29
The idea behind the inside-edge scope addition is to ensure that any
binding form that appears as during an expansion is constrained to bind
within the definition scope (i.e., not establish a binding for some
arbitrary other context). The affect on the `let` binding here seems
like an unfortunate side effect of the way that constraint is
implemented.
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
racket-users...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/racket-users/b1a999bb-cc3a-4da8-ae31-11e5a3bf
> f7d6%
40googlegroups.com.