[racket-dev] zo-parse and implicit requires from template-phased syntax?
I'm chasing after a bug in Whalesong, and I've narrowed it down to the
following.
Suppose I have a small helper:
;; helper.rkt
#lang racket/base
(require (for-template racket/list racket/base))
(provide get-code)
(define (get-code stx)
#`(second #,stx))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
The function "get-code" generates a single object that expects its
context to have instantiated the racket/list library.
I then use it in a small test.rkt file:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket/base
(require (for-syntax "helper.rkt" racket/base))
(define-syntax (s stx)
(syntax-case stx ()
[(_ x)
(get-code #'x)]))
(s '(a b c))
(s '("one" "two" "three"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
When I inspect the run-time requires necessary to execute test.rkt, I
expect to see two modules, racket/base and helper.rkt, in the list
associated to phase 0.
However, I don't see this. Here's quick-and-dirty code to demonstrate:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket/base
(require compiler/zo-parse)
(read-accept-reader #t)
(current-namespace (make-base-namespace))
(define a-top
(let* ([code (compile (read (open-input-file "temp.rkt")))]
[op (open-output-bytes)])
(write code op)
(zo-parse (open-input-bytes (get-output-bytes op)))))
(define a-mod
(compilation-top-code a-top))
(define a-requires
(mod-requires a-mod))
(define (self-mpi? a-mpi)
(define-values (m b) (module-path-index-split a-mpi))
(and (eq? m #f) (eq? b #f)))
(define (mpi->string a-mpi)
(cond
[(self-mpi? a-mpi)
"self"]
[else
(path->string (resolved-module-path-name
(module-path-index-resolve a-mpi)))]))
;; Just print the runtime modules being required:
(for [(phase+mpis a-requires)
#:when (equal? (car phase+mpis) 0)]
(define mpis (cdr phase+mpis))
(for ([a-mpi mpis])
(printf "~s\n" (mpi->string a-mpi))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Instead, I see just racket/base. Am I misunderstanding that
mod-requires doesn't fully enumerate run-time dependencies?