The error message is intended for "end users" and turns out to be misleading for the implementor of an internal-definition context. The documentation for `define-values` has essentially the same problem: it describes how `define-values` should work in an internal-definition context, but it doesn't say how the form interacts with `local-expand`.
A `define-values` form will only expand in a module or top-level context. To implement an internal-definition context, you must expand only far enough to see `define-values` form; in other words, supply `#'define-values` in the stop list. Then, a partially expanded `define-values` form must be recognized and handled explicitly, with tools like `syntax-local-bind-syntaxes` or re-writing to `letrec-values`, as appropriate for the definition context. At Mon, 05 Jan 2015 14:49:03 +0000, Spencer Florence wrote: > Hey all, > > I'm trying to use 'local-expand', however it seems to think its never in a > definition context. For example: > > (require (for-syntax syntax/parse)) > (define-syntax (test stx) > (syntax-parse stx > [(_ e) > (define ctx > (if (list? (syntax-local-context)) > (cons (gensym) (syntax-local-context)) > (list (gensym)))) > (local-expand > #'e ctx null > ;; result is the same with this uncommented > #;(syntax-local-make-definition-context))])) > (let () > (test (define x 1)) > x) > > errors with a "define-values: not in a definition context in: > (define-values (x) 1)" > > Can anyone provide any insight into what is going on? > > --spf > ____________________ > Racket Users list: > http://lists.racket-lang.org/users ____________________ Racket Users list: http://lists.racket-lang.org/users