Changed early failure in subtyping to all non-struct values, not just null. Closes PR 11887.

original commit: e9683e1dd2f6544391cc603a6385baee59c6c07e
This commit is contained in:
Eric Dobson 2011-05-05 20:16:49 -04:00 committed by Sam Tobin-Hochstadt
parent 26a209d374
commit a5bbee3ce3
2 changed files with 13 additions and 3 deletions

View File

@ -0,0 +1,9 @@
#lang typed/racket
(define-struct: [e f] doll ((inside : (Option (doll e f)))
(elt1 : e)
(elt2 : f)))
(: singleton (All (e f) (e f -> (doll e f))))
(define (singleton e f)
(make-doll #f e f))

View File

@ -6,6 +6,7 @@
(env type-name-env)
(only-in (infer infer-dummy) unify)
racket/match unstable/match
racket/function
(rename-in racket/contract
[-> c->] [->* c->*])
(for-syntax racket/base syntax/parse))
@ -277,10 +278,10 @@
(fail! s t)]
[((or (? Struct? s1) (NameStruct: s1)) (Base: _ _ _ _))
(fail! s t)]
;; same for Null
[((Value: '()) (or (? Struct? s1) (NameStruct: s1)))
;; same for all values.
[((Value: (? (negate struct?) _)) (or (? Struct? s1) (NameStruct: s1)))
(fail! s t)]
[((or (? Struct? s1) (NameStruct: s1)) (Value: '()))
[((or (? Struct? s1) (NameStruct: s1)) (Value: (? (negate struct?) _)))
(fail! s t)]
;; just checking if s/t is a struct misses recursive/union/etc cases
[((? (lambda (_) (eq? ks 'struct))) (Base: _ _ _ _)) (fail! s t)]