Adjust type variable syntax for typed classes

This makes it consistent with other forms like the
new `lambda` form.
This commit is contained in:
Asumu Takikawa 2014-02-21 11:47:08 -05:00
parent 315034bbe5
commit 8ce376f503
3 changed files with 6 additions and 8 deletions

View File

@ -50,8 +50,8 @@ library.
expr
(begin class-clause ...)]
[maybe-type-parameters (code:line)
(code:line #:forall type-variable)
(code:line #:forall (type-variable ...))]
(code:line #:forall (type-variable ...))
(code:line #: (type-variable ...))]
[init-decl id/type
[renamed]
[renamed : type-expr]

View File

@ -123,9 +123,7 @@
(:))
(define-splicing-syntax-class maybe-type-parameter
(pattern (~seq #:forall type-variable:id)
#:attr type-variables #'(type-variable))
(pattern (~seq #:forall (type-variable:id ...))
(pattern (~seq (~or #:∀ #:forall) (type-variable:id ...))
#:attr type-variables #'(type-variable ...))
(pattern (~seq)
#:attr type-variables #'()))

View File

@ -3322,7 +3322,7 @@
[tc-e (let ()
(define point%
(class object%
#:forall X
#:(X)
(super-new)
(init-field [x : X] [y : X])))
(new (inst point% Integer) [x 0] [y 5])
@ -3359,13 +3359,13 @@
#:msg #rx"expected: X.*given: String"]
;; fails because default init value cannot be polymorphic
[tc-err (class object%
#:forall Z
#:forall (Z)
(super-new)
(init-field [x : Z] [y : Z 0]))
#:msg #rx"Default init value has wrong type"]
;; fails because default field value cannot be polymorphic
[tc-err (class object%
#:forall Z
#:forall (Z)
(super-new)
(field [x : Z "a"]))
#:msg #rx"expected: Z.*given: String"]