[racket-dev] [plt] Push #26832: master branch updated

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Mon May 13 23:51:42 EDT 2013

On Mon, May 13, 2013 at 2:14 PM,  <asumu at racket-lang.org> wrote:
> asumu has updated `master' from a857256c77 to f3e6276f9b.
>   http://git.racket-lang.org/plt/a857256c77..f3e6276f9b
>
> =====[ One Commit ]=====================================================
> Directory summary:
>   29.0% collects/tests/typed-racket/succeed/
>   70.9% collects/typed-racket/typecheck/
>
> ~~~~~~~~~~
>
> f3e6276 Asumu Takikawa <asumu at racket-lang.org> 2013-05-13 16:47
> :
> | Make `define-type` work at top-level
> |
> | Closes PR 12913
> :
>   A collects/tests/typed-racket/succeed/pr12913.rkt
>   M collects/typed-racket/typecheck/tc-toplevel.rkt | 14 +++++++++++---
>
> =====[ Overall Diff ]===================================================
>
> collects/tests/typed-racket/succeed/pr12913.rkt
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> --- /dev/null
> +++ NEW/collects/tests/typed-racket/succeed/pr12913.rkt
> @@ -0,0 +1,10 @@
> +#lang racket
> +
> +;; Test that `define-type` works at the top-level
> +
> +(define ns (make-base-namespace))
> +(eval '(require typed/racket) ns)
> +(eval '(define-type Foo (U String Symbol)) ns)
> +(eval '(: x Foo) ns)
> +(eval '(define x 'x) ns)
> +
>
Is there a reason to do this this way instead of using racket/load?


> collects/typed-racket/typecheck/tc-toplevel.rkt
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> --- OLD/collects/typed-racket/typecheck/tc-toplevel.rkt
> +++ NEW/collects/typed-racket/typecheck/tc-toplevel.rkt
> @@ -417,7 +417,15 @@
>  ;; used only from #%top-interaction
>  ;; syntax -> (values #f (or/c void? tc-results/c))
>  (define (tc-toplevel-form form)
> -  (tc-toplevel/pass1 form)
> -  (begin0 (values #f (tc-toplevel/pass2 form))
> -          (report-all-errors)))
> +  (syntax-parse form
> +    [((~literal begin) e ...)
> +     (for-each tc-toplevel-form (syntax->list #'(e ...)))
> +     (begin0 (values #f (tc-toplevel/pass2 form))
> +             (report-all-errors))]
Isn't this going to tc-loplevel/pass2 the interernal forms of the
begin multiple times?

> +    [_
> +     (when ((internal-syntax-pred define-type-alias-internal) form)
> +       ((compose register-type-alias parse-type-alias) form))
> +     (tc-toplevel/pass1 form)
> +     (begin0 (values #f (tc-toplevel/pass2 form))
> +             (report-all-errors))]))
>

Posted on the dev mailing list.