[racket] let-syntax referencing inner binding
The code mostly speaks for itself but I'm wondering why the reference to
`test2' is a compilation error.
#lang racket
(define-for-syntax (test)
(printf "hello from test\n")
#'1)
(define-for-syntax (do-it stx)
(define (test2)
(printf "hello from test2\n")
#'2)
;; ok, prints "hello from test"
#'(let-syntax ([bar (lambda (s)
(test))])
(bar))
;; doesn't compile, compile: identifier used out of context in: test2
#;
#'(let-syntax ([bar (lambda (s)
(test2))])
(bar)))
(define-syntax (foo stx)
(do-it stx))
(foo)
#|
;; this fails because a reference is made to a binding at phase 1 from
phase 0 code
;; compile: identifier used out of context in: p
(define-syntax (xx stx)
(define p 2)
#'p)
(xx)
|#