[racket] web-server/templates: "require: not at module level or top level"

From: Greg Hendershott (greghendershott at gmail.com)
Date: Thu Nov 28 09:32:11 EST 2013

It looks like there's a corner case where `local-require` does not
work -- with non-simple require specs such as `rename-in` or
`prefix-in`, AND where the module is the #lang module.

This works with normal require:

#lang racket
(require (rename-in racket [string rkt:string]))
(rkt:string #\a #\b) ;=> "ab"

But this does not:

#lang racket
(let ()
  (local-require (rename-in racket [string rkt:string]))
  ;;=> 3:28: syntax: misplaced ellipsis in template at: ... in: ...
  (rkt:string #\a #\b))

Something like...

#lang racket
(let ()
  (local-require (rename-in net/url [get-pure-port foo]))
  ...

...does compile OK. So it seems specific to it being the #lang or
perhaps specific to `racket`.

I'll report this as a not-critical bug. (Even if it's not a bug in the
sense that there's a good reason why it ought not to work? The error
message could be better and/or the docs for local-require might
explain this.)

Posted on the users mailing list.