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

This commit is contained in:
Eric Dobson 2011-05-05 20:16:49 -04:00 committed by Sam Tobin-Hochstadt
parent 240d95ada6
commit e9683e1dd2
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) (env type-name-env)
(only-in (infer infer-dummy) unify) (only-in (infer infer-dummy) unify)
racket/match unstable/match racket/match unstable/match
racket/function
(rename-in racket/contract (rename-in racket/contract
[-> c->] [->* c->*]) [-> c->] [->* c->*])
(for-syntax racket/base syntax/parse)) (for-syntax racket/base syntax/parse))
@ -277,10 +278,10 @@
(fail! s t)] (fail! s t)]
[((or (? Struct? s1) (NameStruct: s1)) (Base: _ _ _ _)) [((or (? Struct? s1) (NameStruct: s1)) (Base: _ _ _ _))
(fail! s t)] (fail! s t)]
;; same for Null ;; same for all values.
[((Value: '()) (or (? Struct? s1) (NameStruct: s1))) [((Value: (? (negate struct?) _)) (or (? Struct? s1) (NameStruct: s1)))
(fail! s t)] (fail! s t)]
[((or (? Struct? s1) (NameStruct: s1)) (Value: '())) [((or (? Struct? s1) (NameStruct: s1)) (Value: (? (negate struct?) _)))
(fail! s t)] (fail! s t)]
;; just checking if s/t is a struct misses recursive/union/etc cases ;; just checking if s/t is a struct misses recursive/union/etc cases
[((? (lambda (_) (eq? ks 'struct))) (Base: _ _ _ _)) (fail! s t)] [((? (lambda (_) (eq? ks 'struct))) (Base: _ _ _ _)) (fail! s t)]