Fix new error messages for class/object types

Closes PR 14942
This commit is contained in:
Asumu Takikawa 2015-01-21 13:54:18 -05:00
parent 8e63b14f4c
commit 5c090ba686
3 changed files with 12 additions and 5 deletions

View File

@ -53,10 +53,8 @@
"type variables bound in different scopes")]
[((? Class?) (? Class?))
(class-mismatch r1 r2)]
[((Instance: c1) (Instance: c2))
(define r1 (resolve c1))
(define r2 (resolve c2))
(class-mismatch r1 r2 #t)]
[((Instance: (app resolve (? Class? c1))) (Instance: (app resolve (? Class? c2))))
(class-mismatch c1 c2 #t)]
;; Don't call this with resolved types since we may want to print
;; the type alias name instead of the actual type
[(_ _) (type-mismatch t1 t2)]))

View File

@ -498,6 +498,7 @@
[(Syntax: t) `(Syntaxof ,(t->s t))]
[(Instance: (and (? has-name?) cls)) `(Instance ,(t->s cls))]
[(Instance: (? Class? cls)) (class->sexp cls #:object? #t)]
[(Instance: t) `(Instance ,(t->s t))] ; for cases like Error
[(ClassTop:) 'ClassTop]
[(? Class?) (class->sexp type)]
[(Result: t (or (NoFilter:) (FilterSet: (Top:) (Top:))) (or (NoObject:) (Empty:))) (type->sexp t)]

View File

@ -1792,4 +1792,12 @@
(ann (class object% (super-new) (init-rest [rst : (Listof String)]))
(Class (init-rest (Listof Void))))
(error "foo"))
#:msg #rx"expected: \\(Listof Void\\).*given: \\(Listof String\\)"]))
#:msg #rx"expected: \\(Listof Void\\).*given: \\(Listof String\\)"]
;; PR 14942
[tc-err (let ()
(: x (Instance BadAlias))
(define x (error "foo"))
(: y (Object (field [x Any])))
(define y x)
(error "foo"))
#:msg "parse error in type"]))