From 90674cf9b20daa480b6df8bec4455e214fc451ca Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Fri, 21 Oct 2011 10:54:56 -0400 Subject: [PATCH] Fix wrapping of `null' when provided as `Any'. Reported by 'dingfeng' on #racket. Please merge to 5.2. (cherry picked from commit da5b68fd4d944cef981062de5ed6d283a351fd1d) --- collects/tests/typed-racket/succeed/any-wrap-list.rkt | 11 +++++++++++ collects/typed-racket/utils/any-wrap.rkt | 3 +++ 2 files changed, 14 insertions(+) create mode 100644 collects/tests/typed-racket/succeed/any-wrap-list.rkt diff --git a/collects/tests/typed-racket/succeed/any-wrap-list.rkt b/collects/tests/typed-racket/succeed/any-wrap-list.rkt new file mode 100644 index 0000000000..9576df4b77 --- /dev/null +++ b/collects/tests/typed-racket/succeed/any-wrap-list.rkt @@ -0,0 +1,11 @@ +#lang racket/load + +(module m typed/racket + (provide f) + (define: f : Any '(a (2 3)))) + +(module n racket + (require 'm) + (list? (second f))) + +(require 'n) diff --git a/collects/typed-racket/utils/any-wrap.rkt b/collects/typed-racket/utils/any-wrap.rkt index 9974543c2e..ce72581899 100644 --- a/collects/typed-racket/utils/any-wrap.rkt +++ b/collects/typed-racket/utils/any-wrap.rkt @@ -7,12 +7,15 @@ (lambda (v p write?) (fprintf p "#" (any-wrap-val v)))) +(define undef (letrec ([x x]) x)) + (define (traverse wrap?) (define (t v) (match v [(? (lambda (e) (and (any-wrap? e) (not wrap?)))) (any-wrap-val v)] [(? (lambda (e) (or (number? e) (string? e) (char? e) (symbol? e) + (null? e) (regexp? e) (eq? undef e) (keyword? e) (bytes? e) (boolean? e) (void? e)))) v] [(cons x y) (cons (t x) (t y))]